in reply to Re: XML::LibXML and too many namespace declarations
in thread XML::LibXML and too many namespace declarations

It works, but from the DOM perspective, the nodes created by createElement don't seem to have any namespace attached

use strict; use XML::LibXML; my $ns = 'http://www.example.com'; my $doc = XML::LibXML::Document->new; $doc->setDocumentElement($doc->createElementNS($ns, 'q:one')); my $elem_two = $doc->documentElement->appendChild($doc->createElement +NS($ns, 'q:two')); my $elem_three = $doc->documentElement->appendChild($doc->createElemen +t('q:three')); warn $doc->toString(1); # look at the namespace in DOM warn 'namespace of q:two is ', $elem_two->namespaceURI, "\n"; warn 'namespace of q:three is ', $elem_three->namespaceURI, "\n"; # via findnodes warn 'q:* nodes are ', join (',', map {$_->nodeName} $doc->documentEle +ment->findnodes('//q:*')), "\n";

The result is:

<?xml version="1.0"?> <q:one xmlns:q="http://www.example.com"> <q:two xmlns:q="http://www.example.com"/> <q:three/> </q:one> namespace of q:two is http://www.example.com namespace of q:three is q:* nodes are q:one,q:two

Moreover the manual of XML::LibXML::DOM states:

It is also important to repeat the specification: While working with namespaces you should use the namespace aware functions instead of the simplified versions.