This content has been marked as final. Show 3 replies
You need to use a namespace object and an e4x expression. Your code will look something like this:
var ns:Namespace = new Namespace(" http://fakenamespace");
var parisList:XMLList = testXML.ns::b;
note the :: between the ns & the b. ns b is the value that you're trying to match and putting the :: before it allows you to specify its namespace.
Unfortunately in my real scenario I don't know what the element will be called. It could be in <foo> or <bar> etc, so I need to be able to use a variable (in which the element name is set beforehand). With "::" I can't use a variable, so textXML.ns::findParis looks for a "findParis" element and not "b".
That's why I'm trying to use testXML.child(findParis) because I can use a variable. I just can't figure out how to make it incorporate the namespace as well.
I figured out the solution. the child() method uses the default namespace to search for the element name. Since I couldn't figure out how to specify a different namespace in the method call, just set the default namespace before you call child to the namespace of the element.