Jump to content


Cannot Traverse XML Loaded Via XMLLoader

Recommended Posts

I've got a really weird problem: I have XML that's getting loaded via XMLLoader. When I assign it to an XML object, I can not access any of the nodes inside it. Here's the code:


// XML (inside an external file)

var myLoader:XMLLoader = new XMLLoader(_settings.loadDataURL, {name:"loadData", onComplete:onLoadData, onError:onLoaderError});

private function onLoadData(e:LoaderEvent):void
var _dataXML:XML = e.target.content;
trace(_dataXML); // Outputs the correct XML
trace(_dataXML.angle[0]); // Outputs "undefined"
trace(_dataXML.children()); // Outputs both of the angle nodes correctly
trace(_dataXML.angle.length()); // Outputs 0


So although the XML data is getting loaded, and it's getting added to _dataXML, but whenever I try to access anything directly inside _dataXML, Flash thinks it doesn't exist. WTF? I feel like I'm missing something obvious but I've been banging my head against this for hours. Any ideas why this would be happening?


Thanks in advance,


Link to comment
Share on other sites

Looks like the problem is that you've got an xmlns attribute defined. Remove that and you're golden.

Link to comment
Share on other sites

Wow - it's always the simplest thing that causes the biggest problems.


Thanks much!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.