A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Problem traversing XML file.

Hybrid View

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    26

    Problem traversing XML file.

    I am having a problem traversing an xml file. I can get the last item of the xml file with the code below but I want all the items. Any ideas? TIA.

    Actionscript Code:
    var rssLoader:URLLoader = new URLLoader();
    rssLoader.addEventListener(Event.COMPLETE, showXML);
    rssLoader.load(new URLRequest("rss_co.rss"));

    function showXML(e:Event):void
        {
        var rssXML:XML = new XML(e.target.data);
        for (var i:int = 0; i < rssXML.channel.item.length(); i++)
            {
            _constructionTxt.htmlText = rssXML.channel.item[i].pubDate + "<br>" + "<br>" +
            "<b>" + rssXML.channel.item[i].title + "<b>" + "<br>" + "<br>" +
            rssXML.channel.item[i].description + "<br>" + "<br>";

            }
        }

    Actionscript Code:
    <?xml version="1.0" ?>
    <rss version="2.0">
    <channel>
        <title></title>
        <description></description>
        <language></language>
        <pubDate></pubDate>
        <lastBuildDate></lastBuildDate>
        <managingEditor></managingEditor>
            <webMaster></webMaster>
        <link></link>
        <ttl></ttl>
        <item>
        `   <title></title>
            <description></description>
            <link></link>
            <pubDate></pubDate>
        </item>
        <item>
            <title></title>
            <description></description>
            <link></link>
            <pubDate></pubDate>
        </item>
        <item>
            <title></title>
            <description></description>
            <link></link>
            <pubDate></pubDate>
        </item>
    </channel>
    </rss>

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You are resetting the htmlText every time through the loop. Use += instead of = if you want to append.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    26
    Quote Originally Posted by 5TonsOfFlax View Post
    You are resetting the htmlText every time through the loop. Use += instead of = if you want to append.
    Thank you! Solved.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center