A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [f8][as2] Reading an XML doc from an RSS feed

  1. #1
    Senior Member
    Join Date
    Jun 2006
    Location
    Charlotte, NC
    Posts
    120

    [f8][as2] Reading an XML doc from an RSS feed

    Greetings all...
    I've worked w/ XML docs before, but only ones i've formatted myself and now i'm trying to read one from an RSS feed... so i'm not a good enough hack to figure it out...

    i've got the feed coming in, and the XML generated is below... but what i need to do is get the <item> and their children (particularly <teaser>, <title>, <link> and <imageUrl>- but can't seem to figure it out. I'm good w/ putting them into arrays and then pulling out the info once i know how to access those nodes... i'm just stuck right now do to limited experience...

    XML file:
    Code:
    <?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="http://francerevisited.com/main" xmlns:dc="http://purl.org/dc/elements/1.1/">
      <channel>
     <title></title>
     <link>http://francerevisited.com/main</link>
     <description>FR-featured-articles</description>
     <language>en</language>
    <item>
     <title>Heard and Overheard in Berlin</title>
     <link>http://francerevisited.com/main/node/80</link>
     <description>&lt;p&gt;&lt;a href=&quot;http://francerevisited.com/main/node/80&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
     <comments>http://francerevisited.com/main/node/80#comments</comments>
     <category domain="http://francerevisited.com/main/taxonomy/term/19">No</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/13">Encounters</category>
     <imageUrl>sites/default/files/BerlinQuotes.jpg</imageUrl>
     <teaser>&lt;div&gt;&lt;b&gt;1.&lt;/b&gt; German in his 60s watching a television interview in which an American military official is explaining NATO maneuvers in the Black Sea: &amp;ldquo;Americans used to be so beautiful in uniform. I would see one and think, &amp;lsquo;There is a beautiful, strong, kind creature.&amp;rsquo; But now&amp;mdash;look at them. They sound so false, devious. Look&amp;mdash;bad skin&amp;hellip; and those eyes!
    
    &lt;/div&gt;</teaser>
     <pubDate>Tue, 23 Sep 2008 10:49:59 +0000</pubDate>
     <dc:creator>gary</dc:creator>
     <guid isPermaLink="false">80 at http://francerevisited.com/main</guid>
    </item>
    <item>
     <title>Biking in Berlin</title>
     <link>http://francerevisited.com/main/node/79</link>
     <description>&lt;p&gt;&lt;a href=&quot;http://francerevisited.com/main/node/79&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
     <comments>http://francerevisited.com/main/node/79#comments</comments>
     <category domain="http://francerevisited.com/main/taxonomy/term/19">No</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/47">Berlin</category>
     <imageUrl>sites/default/files/BerlinBiking.jpg</imageUrl>
     <teaser>&lt;div&gt;With its wide roads, extensive bike lanes, traffic-light abiding citizens, and numerous bicycle rental shops, Berlin may well be the best biking city in Europe.
    
    &lt;/div&gt;</teaser>
     <pubDate>Sun, 21 Sep 2008 22:58:00 +0000</pubDate>
     <dc:creator>gary</dc:creator>
     <guid isPermaLink="false">79 at http://francerevisited.com/main</guid>
    </item>
    <item>
     <title>Paris on the Run: A Guide for the Jogging Traveler</title>
     <link>http://francerevisited.com/main/node/57</link>
     <description>&lt;p&gt;&lt;a href=&quot;http://francerevisited.com/main/node/57&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
     <comments>http://francerevisited.com/main/node/57#comments</comments>
     <category domain="http://francerevisited.com/main/taxonomy/term/19">No</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/1">Paris</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/10">Explorations</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/28">Nature and Sport</category>
     <imageUrl>sites/default/files/ParisJogging.jpg</imageUrl>
     <teaser>&lt;div&gt;Paris&amp;rsquo;s compact beauty, regularly spaced parks and gardens, and romantic stretch of river make this one of the world&amp;rsquo;s most beloved walking cities. Now strap on a pair of running shoes and you&amp;rsquo;ll find that those same elements add up to a great jogging city as well.&lt;/div&gt;
    
    &lt;div&gt;&amp;nbsp;&lt;/div&gt;
    &lt;div&gt;Large swaths of the city can be viewed in a street-and-sidewalk run.
    &lt;/div&gt;</teaser>
     <pubDate>Sat, 06 Sep 2008 16:24:10 +0000</pubDate>
     <dc:creator>gary</dc:creator>
     <guid isPermaLink="false">57 at http://francerevisited.com/main</guid>
    </item>
    
    <item>
     <title>The Class: Inside the Walls of French Education</title>
     <link>http://francerevisited.com/main/node/55</link>
     <description>&lt;p&gt;&lt;a href=&quot;http://francerevisited.com/main/node/55&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
     <comments>http://francerevisited.com/main/node/55#comments</comments>
     <category domain="http://francerevisited.com/main/taxonomy/term/19">No</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/1">Paris</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/12">Dimmed Lights</category>
     <imageUrl>sites/default/files/Tempimage.jpg</imageUrl>
     <teaser>&lt;div&gt;Laurent Cantet&amp;rsquo;s film &lt;i&gt;The Class&lt;/i&gt; (&lt;i&gt;Entre les murs&lt;/i&gt;) won the prestigious Palme d&amp;rsquo;Or at this year&amp;rsquo;s Cannes Film Festival,&amp;nbsp;earning&amp;nbsp;high praise&amp;nbsp;for its lively portrayal of adolescents in a Parisian high school, and is now France&#039;s official entry for the 2009 Oscar in the Foreign Language Film Category.&amp;nbsp;Rather than create a stilted picture of youth,&amp;nbsp;the film gives a startling vision of the real energy of thirteen-year-olds.&lt;/div&gt;
    
    &lt;div&gt;&amp;nbsp;&lt;/div&gt;
    &lt;div&gt;To make this film Mr.
    &lt;/div&gt;</teaser>
     <pubDate>Fri, 05 Sep 2008 10:25:35 +0000</pubDate>
     <dc:creator />
     <guid isPermaLink="false">55 at http://francerevisited.com/main</guid>
    </item>
    <item>
     <title>Wealth and Politics: An East-West Primer for Paris and the Surrounding Region</title>
     <link>http://francerevisited.com/main/node/46</link>
     <description>&lt;p&gt;&lt;a href=&quot;http://francerevisited.com/main/node/46&quot; target=&quot;_blank&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
     <comments>http://francerevisited.com/main/node/46#comments</comments>
     <category domain="http://francerevisited.com/main/taxonomy/term/19">No</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/1">Paris</category>
     <category domain="http://francerevisited.com/main/taxonomy/term/10">Explorations</category>
     <imageUrl>sites/default/files/LegislativeMap2007_1.jpg</imageUrl>
     <teaser>&lt;div&gt;The French electorate doesn&amp;rsquo;t necessarily vote according to its relative wealth, yet relative wealth is a pretty good indicator of voting strength, particularly in Paris and more dramatically in its surrounding region. There, generally speaking, flourishing professionals, and international business mark the west and southwest suburbs while working class, welfare recipients, and immigrants define the east and north suburbs.
    
    &lt;/div&gt;</teaser>
     <pubDate>Thu, 21 Aug 2008 19:18:03 +0000</pubDate>
     <dc:creator>gary</dc:creator>
     <guid isPermaLink="false">46 at http://francerevisited.com/main</guid>
    </item>
    </channel>
    </rss>
    the start of my AS2 code:
    Code:
    _xml = new XML();
    _xml.ignoreWhite = true;
    _xml.load("http://www.francerevisited.com/main/front-fa/");
    _xml.onLoad = function() {
    	cNode = this.firstChild.firstChild.childNodes;
    	trace(cNode);
    	_root.teaserArr = new Array();
    	_root.titleArr = new Array();
    	_root.imageArr = new Array();
    	_root.linkArr = new Array();
    	_root.cnt = cNode.length;
    	for (var n = 0; n<_root.cnt; n++) {
    		_root.teaserArr[n] = cNode[n].attributes.teaser;
    		_root.titleArr[n] = cNode[n].attributes.title;
    		_root.imageArr[n] = cNode[n].attributes.imageUrl;
    		_root.linkArr[n] = cNode[n].attributes.link;
    	}
    };

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    the xml is not overly well-formed
    the closest you can get is -
    PHP Code:
    _xml = new XML();
    _xml.ignoreWhite true;
    _xml.load("rs.xml"); // copied the rss to an xml file for testing

    _xml.onLoad = function() {
        
    cNode this.firstChild.firstChild.childNodes;
        
    cnt cNode.length;
        
    _root.titleArr = new Array();
        
    _root.linkArr = new Array();
        
    _root.imageArr = new Array();
        
    _root.teaserArr = new Array();
    for (var 
    0m<cntm++) {
        
    cnt2 cNode[m].childNodes.length;
    for (var 
    0n<cnt2n++) {
            
    _root.titleArr[n] = cNode[m].childNodes[0].firstChild.nodeValue;
            
    _root.linkArr[n] = cNode[m].childNodes[1].firstChild.nodeValue;
            
    _root.imageArr[n] = cNode[m].childNodes[7].firstChild.nodeValue;
            
    _root.teaserArr[n] = cNode[m].childNodes[8].firstChild.nodeValue;
    }
    }    
    }; 

  3. #3
    Senior Member
    Join Date
    Jun 2006
    Location
    Charlotte, NC
    Posts
    120
    Thanks, i will try this...

    and yes, the XML suxors... it's Drupal's idea of an RSS feed...

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