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,
In reply to Swaping xml elements using XML::Twig by aakikce
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |