Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HakimCassimallyBBC/707e4df3900896ad59cfc6995cb03383 to your computer and use it in GitHub Desktop.
Save HakimCassimallyBBC/707e4df3900896ad59cfc6995cb03383 to your computer and use it in GitHub Desktop.
xml sketch
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