5 Replies Latest reply on Jun 20, 2012 6:51 PM by Ned Murphy

    Load Rss with separate image

    Igor R. Gomes

      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



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


                                    <description><![CDATA[<img src='http://static.guim.co.uk/sys-images/Observer/Pix/pictures/2012/2/24/1330125475757/Presiden t-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>



      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.

        • 1. Re: Load Rss with separate image
          Ned Murphy Adobe Community Professional & MVP

          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).

          1 person found this helpful
          • 2. Re: Load Rss with separate image
            Igor R. Gomes Level 1

            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[b].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[b].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!

            • 3. Re: Load Rss with separate image
              Ned Murphy Adobe Community Professional & MVP

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

              • 4. Re: Load Rss with separate image
                Igor R. Gomes Level 1

                Do you have some sample to show me, i have little difficult to understand...

                • 5. Re: Load Rss with separate image
                  Ned Murphy Adobe Community Professional & MVP

                  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);



                  1 person found this helpful