in reply to removing namespaces with XML::Twig?
I tried the obvious of taking the example for "map_xmlns" and seeing if I could substitute an empty prefix. The result was that it leaves the prefix unchanged:
#!/usr/bin/perl #very slightly modified example lifted from the docs use strict; use warnings; use XML::Twig; my $t= XML::Twig->new( map_xmlns => {'http://www.w3.org/2000/svg' => " +"}, twig_handlers => { 'svg:circle' => sub { $_->set_att( r => 2 +0) } }, pretty_print => 'indented', ) ->parse( '<doc xmlns:gr="http://www.w3.org/2000/svg" +> <gr:circle cx="10" cy="90" r="10"/> </doc>' ) ->print;
The output is:
<doc xmlns:gr="http://www.w3.org/2000/svg"> <gr:circle cx="10" cy="90" r="10"/> </doc>
If I put the "svg"in the example back in the hash, it works as in the example. If I put a space, I get a prefix that's a space and a colon. XML::LibXML::Element will let you turn off the namespace prefix element by element, but I'm too lazy right now to work through that one. Try poking around through the various XML::LibXML children.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: removing namespaces with XML::Twig?
by Anonymous Monk on Jun 12, 2012 at 06:24 UTC |