aakikce has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
i tried to swap xml elements. I am getting errors as "can't call method move without a package or object reference"
My xml file and code as follows:-
<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> open (FIN, "< in.xml") || "error input xml"; $content = <FIN>; my $twig = XML::Twig->new(pretty_print => 'nice'); $twig->parse($content); $twig->get_xpath('//source')->move('before', $twig->get_xpath('//pages +ource')); $content = $twig->sprint; open (FOUT, ">output.xml") || "error"; print FOUT $content;
Thanks,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Swaping xml elements using XML::Twig
by mirod (Canon) on Apr 27, 2007 at 09:43 UTC | |
Re: Swaping xml elements using XML::Twig
by Samy_rio (Vicar) on Apr 27, 2007 at 09:43 UTC |