I would expect the children() method to return just the last two elements of 
your input XML:

<root xmlns="http://localhost/a"; xmlns:ns="http://localhost/a";>
<elem attr="abc"/>
<elem ns:attr="abc"/>
<ns:elem attr="abc"/>
<ns:elem ns:attr="abc"/>
</root>

as the last two elements are the only ones in the 'http://localhost/a' 
namespace.

No, every element in the document is in the same namespace. The first
two children and the root element are in the namespace by virtue of the
default namespace of the root element; the last two are in the namespace
by virtue of an explicit prefix.

To have those children have no default namespace, it would be necessary
to write something like this:

<root xmlns="http://localhost/a"; xmlns:ns="http://localhost/a";>
<elem xmlns="" attr="abc"/>
<elem xmlns="" ns:attr="abc"/>
<ns:elem attr="abc"/>
<ns:elem ns:attr="abc"/>
</root>

See:

http://www.w3.org/TR/xml-names/#scoping-defaulting

The indentation of the examples is a bit messed up, but you'll see the
same thing done there.

Attributes, however, are a different story. Attributes always need an
explicit prefix to be in a namespace.

Ben.




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to