Subject: | createNode and namespaces |
Nodes are created without namespace
script1:
-----
use strict;
use XML::XPath;
my $xp = new XML::XPath(xml => '<?xml version="1.0" encoding="UTF-8" ?>
<root>
<a>
</a>
</root>');
$xp->createNode('/root/b/@aaa');
$xp->setNodeText('/root/b/@aaa','aaa');
$xp->createNode('/root/b/@ccc');
$xp->setNodeText('/root/b/@ccc','ccc');
$xp->setNodeText('/root/b','xxx');
print $xp->getNodeAsXML();
-----
result (correct) is:
-----
<root>
<a>
</a>
<b aaa="aaa" ccc="ccc">xxx</b></root>
-----
script2:
-----
use strict;
use XML::XPath;
my $xp = new XML::XPath(xml => '<?xml version="1.0" encoding="UTF-8" ?>
<n1:root xmlns:n1="http://n1.zzz.ru" xmlns:n2="http://n2.zzz.ru"
xmlns:n3="http://n3.zzz.ru">
<n2:a>
</n2:a>
</n1:root>');
$xp->createNode('/n1:root/n3:b/@aaa');
$xp->setNodeText('/n1:root/n3:b/@aaa','aaa');
$xp->createNode('/n1:root/n3:b/@ccc');
$xp->setNodeText('/n1:root/n3:b/@ccc','ccc');
$xp->createNode('/n1:root/n3:b');
$xp->setNodeText('/n1:root/n3:b','xxx');
print $xp->getNodeAsXML();
-----
result (bug) is:
-----
<n1:root xmlns:n1="http://n1.zzz.ru" xmlns:n2="http://n2.zzz.ru"
xmlns:n3="http://n3.zzz.ru">
<n2:a>
</n2:a>
<n3:b aaa="" /><n3:b ccc="" /><n3:b /></n1:root>
-----
The proposed patch attached
Subject: | XPath.pm |
Message body is not shown because it is too large.