A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] xPath in Flash ..

  1. #1
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875

    [RESOLVED] xPath in Flash ..

    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 ...:


    Code:
    <CaseStudies>
       <Store>
         <imagegallery>
    	        <image source="images/mask.jpg" />
    		<image source="images/juicer.jpg" />
    		<image source="images/wedding.jpg" />
          </imagegallery>
       </Store> 
    </CaseStudies>
    and my flash is as follows:


    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
    Last edited by silentweed; 01-12-2007 at 07:29 PM.
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    aaargh i think i need a break lol, saving the .xml file would have helped and the remembering firstchild....

    trace(imageNode[0].firstChild.attributes["source"])

    works fine ....
    Last edited by silentweed; 01-12-2007 at 07:30 PM.
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

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