Created
March 16, 2017 13:39
-
-
Save HakimCassimallyBBC/707e4df3900896ad59cfc6995cb03383 to your computer and use it in GitHub Desktop.
xml sketch
This file contains 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
use strict; use warnings; | |
use XML::LibXML; | |
use XML::LibXML::XPathContext; | |
my $xml = <<'__EOI__'; | |
<par xmlns:bar="www.bar.com"><bar:foo/></par> | |
__EOI__ | |
my $parser = XML::LibXML->new(); | |
my $doc = $parser->parse_string($xml); | |
my $node = $doc->lastChild->firstChild; | |
$node->unbindNode; | |
for my $ns ($doc->lastChild->getNamespaces) { | |
$node->addChild($ns); | |
} | |
print $node->serialize(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment