sharing small pieces of rocks or jewels I find on the way

Archive for April, 2008

XPath example

I have used XPath before, recently when I needed I forgot the syntax, so thought of keep it written here. It may come helpful for some others as well

import mx.xpath.XPathAPI;

var xml:XML = new XML();
xml.ignoreWhite = true;
xml.load(“http://api.flickr.com/services/feeds/photos_public.gne?id=67845814@N00&lang=en-us&format=rss_200″);

xml.onLoad = function()
{
    var thumbs:Array = XPathAPI.selectNodeList(this.firstChild, “/rss/channel/item/media:thumbnail”);
    for(var i in thumbs)
    {
        trace(thumbs[i].attributes.url);
    }
}

This tutorial was a great help.

http://tutorials.lastashero.com/2005/10/using_the_xpath_api_in_flash.html