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.

Comment on Re: removing namespaces with XML::Twig?
Select or Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2015-11-27 04:25 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (717 votes), past polls