Last active
August 29, 2015 14:11
-
-
Save dginev/828279d9689417d65a14 to your computer and use it in GitHub Desktop.
libxml 2.9.2 ID conflicts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/perl/bin -w | |
use strict; | |
use warnings; | |
use XML::LibXML; | |
my $xml_content = <<EOL; | |
<?xml version="1.0" encoding="UTF-8"?> | |
<a xml:id="a"> | |
<b xml:id="b"></b> | |
</a> | |
EOL | |
my $dom = XML::LibXML->load_xml(string => $xml_content, no_blanks => 1); | |
my $a = $dom->documentElement; | |
my $b = $a->firstChild; | |
$b->unbindNode(); | |
my $c = $dom->createElement("c"); | |
$c->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'id', "b"); | |
$a->appendChild($c); | |
print $dom->toString(1),"\n"; |
For some reason it didn't even send me a notice ... Thanks for that, removeAttribute should do the trick, we just need to hunt down all positions where we unbind nodes (that we don't reuse later).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, @dginev, so you get a notice! Ha!