Copy link to clipboard
Copied
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-gessen-review</link>
<description><![CDATA[<img src='http://static.guim.co.uk/sys-images/Observer/Pix/pictures/2012/2/24/1330125475757/President-Vladimir...' 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.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.
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
Ned, thanx for you attention, but i can understand how doing what you say... i can't edit the rss text, cause is load from one site that i don't have access...
but i tried one solution for create a link
textBox.appendText( "<a href= \u0022" + theXMLData.channel.item.link + "\u0022 >Click Here </a>" );
this works fine, but... the tag "<img src=..." is different of tag <link>
this make difficult to create a code for this,
i tried...
textBox.appendText( "<img src= \u0022" + theXMLData.channel.item.img + "\u0022/>" );
but doesn't works...
you can think something like this to solve the problem of load image?
Thank for all..
ps: thankyou for substring, this solved the problem!
Copy link to clipboard
Copied
My solutions are not talking about editing the rss on the server. You edit it when you parse it after loading the data.
Copy link to clipboard
Copied
Do you have some sample to show me, i have little difficult to understand...
Copy link to clipboard
Copied
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);