Skip navigation
Igor R. Gomes
Currently Being Moderated

Load Rss with separate image

Jun 20, 2012 9:12 AM

Tags: #image #3.0 #xml #reader #rss #load #as

Hello folks,

 

I have to load rss live on swf. But when i load the tag <description> it loads with the content image tag. <img src=...>, he is the code of xml.rss

 

<item>

                              <title><![CDATA[Man without face]]></title>

                              <link>http://www.guardian.co.uk/books/2012/feb/26/vladimir-putin-masha-gesse n-review</link>

                              <description><![CDATA[<img src='http://static.guim.co.uk/sys-images/Observer/Pix/pictures/2012/2/24/13 30125475757/President-Vladimir-Putin--007.jpg' align="left" />       In an article for the website slon.ru, Alexander Baunov recently recalled... etc ]]></description>

              <pubDate>Qua, 20 Jun 2012 12:35:02 -0300</pubDate>

                    </item>

 

In my as i have a textbox(called textBox), that get the xml loaded... and i use the code:

 

textBox.appendText( theXMLData.channel.item[b].description );

this code get all parse of tag description, and show the image before text. But i don't whant this. I whant to ignore the tag <img src="http...>

 

In truth, i have antoher box called (imgBox), i need to load this image on this box.

Someone can help-me?

 

 

 

ps: by the way, when i load the tag <pubDate> appears the date with all caracters, including the number "-0300", its possible clear this number on the end?

 

Thank for all,

 

Igor R.

 
Replies
  • Currently Being Moderated
    Jun 20, 2012 9:40 AM   in reply to Igor R. Gomes

    For the description field you will probably need to use the RegExp class to isolate the <img... > tag and the text that follows as two separate pieces.  You could also use the /> of the image tag aling with the String class's lastIndexOf() method to divide and conquer, creatuing substrings around it being there.  THe first substring from the start of the string to the index of the ">"  and the secodn substring starting there to the end of the string.

     

    For the pubDate field you there are a couple options.  One way would be to seek out the lastIndexOf(":") in that string and then get a substring from it that cuts it off two characters later (to keep the seconds value).

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 11:10 AM   in reply to Igor R. Gomes

    My solutions are not talking about editing the rss on the server. You edit it when you parse it after loading the data.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 6:51 PM   in reply to Igor R. Gomes

    When you parse that description tag from the xml you will end up with a string.  Just take that string and do something like the following (the first line is the string you extract, slightly modified)...

     

    // this is the parsed line from the xml data feed

    var desc:String = "<img src='http://static.guim.co.uk/007.jpg' /> In an article for the website, etc...";

     

    // here you extract the image portion

    var descImg:String = desc.substr(desc.indexOf("<"),desc.indexOf(">")+1);

     

    // here you extract the text portion after the image
    var descText:String = desc.substr(desc.indexOf(">")+1);

     

    trace(descImg);
    trace(descText);

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points