Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Swaping xml elements using XML::Twig

by Samy_rio (Vicar)
on Apr 27, 2007 at 09:43 UTC ( #612342=note: print w/ replies, xml ) Need Help??


in reply to Swaping xml elements using XML::Twig

Hi aakikce, Try this,

use strict; use warnings; use XML::Twig; my $twig = XML::Twig->new(pretty_print => 'nice'); $twig->parse(\*DATA); $_->move('before', $twig->get_xpath('//pagesource')) for ($twig->findn +odes('//source')); $twig->print; __DATA__ <root> <pagesource> <para>Teacher's Guide Level A</para> <para><graphic alt="title" links="Studio Logo R BW.tif"/></para> </pagesource> <source> <paragraph>ISBN-13: 978-1-4190-4181-5</paragraph> <paragraph>ISBN-10: 1-4190-4181-9</paragraph> </source> <pagesource> <para>Teacher's Guide Level A</para> <para><graphic alt="title" links="Studio Logo R BW.tif"/></para> </pagesource> <source> <paragraph>ISBN-13: 978-1-4190-4181-5</paragraph> <paragraph>ISBN-10: 1-4190-4181-9</paragraph> </source> </root>

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';


Comment on Re: Swaping xml elements using XML::Twig
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://612342]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2015-07-08 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls