×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    11

    Get image from RSS XML

    I am trying to fetch data from an rss feed but I am having a hard time in getting the image of a blog content/post. It seems like the <img> tag is located inside of a
    Code:
    <content:encoded><![CDATA[...]]></content:encoded>
    element.

    the structure of the xml looks like this.

    Code:
    <content:encoded><![CDATA[
    <p><img class="class1" title="hello world" src="http://www.mysite.com/images/myPhoto.jpg" alt="" width="550" height="227" /></p>
    <p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    ]]></content:encoded>
    thanks..

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,748

    Re: Get image from RSS XML

    The src attribute is clearly the URL for the image. Just note that the internal contents are not XML, but loosely formatted HTML, that is why the thing is wrapped into a CDATA (http://en.wikipedia.org/wiki/CDATA, so you will get it as a string practically, which you have to parse afterwards).

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    11

    Re: Get image from RSS XML

    thanks. but how can i get the data inside the <content:encoded> tag? if i can get its value then maybe i can pass it to a string and then parse the <img> tag from it.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,748

    Re: Get image from RSS XML

    According to http://msdn.microsoft.com/en-us/libr...ader.read.aspx, a MoveToContent-Read call is expected to deliver it to you. Even if this particular page does not mention WP7, http://msdn.microsoft.com/en-us/libr...(v=vs.95).aspx seems to offer all of the required methods.

  5. #5
    Registered User
    Join Date
    Feb 2012
    Posts
    11

    Unhappy Re: Get image from RSS XML

    I still could not get the data from the <content:encoded> tag..

    this is my code

    Code:
    XElement xmlFeeds = XElement.Parse(e.Result);
                XNamespace nsContent = "http://feeds.feedburner.com/pinoytechblog";
                listBox1.ItemsSource = from feed in xmlFeeds.Descendants("item")
                                       select new FeedItem
                                       {
                                           Title = feed.Element("title").Value,
                                           Content = feed.Element("content:encoded").Value
                                       };
    if i use
    Code:
    Content = feed.Element("content").Value
    it returns a null error

    if i use
    Code:
    Content = feed.Element("content:encoded").Value
    it returns a The ':' character, hexadecimal value 0x3A, cannot be included in a name error.


  6. #6
    Registered User
    Join Date
    Feb 2012
    Posts
    11

    Re: Get image from RSS XML

    to help anyone who might bump into my thread/question..
    i finally got the content of the <content:encode> tag.

    Code:
    Content = feed.Element(XName.Get("encoded", "http://purl.org/rss/1.0/modules/content/")).Value

Similar Threads

  1. Replies: 1
    Last Post: 2011-12-29, 10:56
  2. Image rotates if movie clip position changed before image loading
    By supriyaakg in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2010-12-30, 03:27
  3. Creating a javax.microedition.lcdui.Image Image on a J2Se environment
    By TacB0sS in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2010-08-24, 20:01
  4. Series 40 - image resizeing and drawing black and white only a part of an image
    By ionutianasi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2003-07-21, 10:36
  5. Replies: 0
    Last Post: 2003-05-12, 17:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×