Writing about web page http://www.xfactorstudio.com/ActionScript/AS2/XPath/
Grrr; want to try some experiments with Flash and a Warwick Blogs RSS feed, search Google for some pointers on parsing feeds using AS, can’t find anything particularly useful so I attempt something anyway, after 2 hours this evening it’s almost working but I’m stuck on something silly, try Google again, find a link to the Actionscript version of the XPathAPI, discover it’s already built into Flash 7, and all I need is the classpath and to drag the Data Binding Classes into the Library to access a really easy way of navigating the feed. 10 mins later I have a lovely collection of arrays full of titles, items, authors etc. plugged into my display array function. I’m sure someone mentioned XPath to me before I started this. Next time I’ll pay attention. For the record;
import mx.xpath.XPathAPI;
var rssfeed_xml = new XML();
rssfeed_xml.ignoreWhite = true;
rssfeed_xml.load(“http://blogs.warwick.ac.uk/showall/newentries/?rss=rss_2_0″);
rssfeed_xml.onLoad = function(success) {
if (success)
{ var titlePath:String = “/rss/channel/item/title”;
title_array = mx.xpath.XPathAPI.selectNodeList(this.firstChild, titlePath);
for (var i = 0; i<title_array.length; i++)
{ trace(title_array[i].firstChild.nodeValue);}}}
etc..
No more of that nextSibling, firstChild multi-function rubbish for me. That turned 4 functions and about 100 lines of code into 20. Conscious incompetence, here I come…
