Hi guys ive just started using XPath today ( but having a slight problem though getting attributes..any tips appreciated.. my XML document is as follows ...:
and my flash is as follows:Code:<CaseStudies> <Store> <imagegallery> <image source="images/mask.jpg" /> <image source="images/juicer.jpg" /> <image source="images/wedding.jpg" /> </imagegallery> </Store> </CaseStudies>
Code:import mx.xpath.XPathAPI; var xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = function(success) { if (success) { var companyPath:String = "/CaseStudies/Store/imagegallery"; var imageNode:Array = mx.xpath.XPathAPI.selectNodeList(this.firstChild, companyPath); trace(imageNode); //this traces out fine trace(imageNode[0].attributes["source"]);//this give undefined } else { trace("error loading XML"); } }; xmlData.load("data.xml");
As u can see above the first trace works fine and outputs:
<imagegallery>
<image source="images/mask.jpg" />
<image source="images/juicer.jpg" />
<image source="images/wedding.jpg" />
</imagegallery>
however
trace(imageNode[0].attributes["source"]);
seems to give undefined...
does anyone know why? Any help appreciated... cheers




Reply With Quote