# Namespaces in xml with e4x

**URL:** <https://forum.kirupa.com/t/namespaces-in-xml-with-e4x/226469>\
**Category:** Uncategorized\
**Created:** [May 21, 2007, 5:37pm UTC](https://forum.kirupa.com/t/namespaces-in-xml-with-e4x/226469 "2007-05-21T17:37:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![devonair](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@devonair](https://forum.kirupa.com/u/devonair)\
**Post date:** [May 21, 2007, 5:37pm UTC](https://forum.kirupa.com/t/namespaces-in-xml-with-e4x/226469/1 "2007-05-21T17:37:17Z")

</div>

This is starting to drive me nuts…

Say, I have the hypothetical xml object:  
[AS]var testXML:XML = \<rootNode xmlns=“[http://www.somedomain.com/](http://www.somedomain.com/)”\>  
\<blah\>Some node\</blah\>  
\<yadda\>Some other node\</yadda\>  
\</rootNode\>[/AS]

and I want to traverse that xml using e4x.

Now, it’s relatively easy to say:  
[AS]namespace ns = “[http://www.somedomain.com/](http://www.somedomain.com/)”;  
trace (testXML.ns::blah); // traces Some node[/AS]

But what if, in theory, I don’t know the namespace uri. The question is: is there a way to declare a namespace using the namespace from an xml object?

I’ve tried:  
[AS]namespace ns = testXML.namespace() as Namespace;  
trace (testXML.ns::blah);[/AS]

but that throws the error:

> 

1171: A namespace initializer must be either a literal string or another namespace.

which doesn’t make any sense as  
[AS](testXML.namespace() as Namespace) is Namespace[/AS]  
returns true. Which seems, at least in my mind, to mean that my namespace initializer \*is \*another namespace.

Any suggestions or ideas greatly appreciated…

d.
