Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: removing namespaces with XML::Twig?

by bitingduck (Chaplain)
on Jun 12, 2012 at 03:45 UTC ( #975682=note: print w/replies, xml ) Need Help??

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 => {'' => " +"}, twig_handlers => { 'svg:circle' => sub { $_->set_att( r => 2 +0) } }, pretty_print => 'indented', ) ->parse( '<doc xmlns:gr="" +> <gr:circle cx="10" cy="90" r="10"/> </doc>' ) ->print;

The output is:

<doc xmlns:gr=""> <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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://975682]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2017-09-22 03:11 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (256 votes). Check out past polls.