aakikce has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I need to grouping heading and its content. I got output by simple regex find and replace. But I need to do it using XML::Twig.
My input is
<root> <ahead>first head</ahead> <x>som text</x> <s>some text</s> <b>some text</b> <k>some text</k> <ahead>first head</ahead> <s>some text</s> <b>some text</b> <k>some text</k> <j>some text</j> </root>
Output
I got the sibling nodes by following code<root> <aheadtext> <ahead>first head</ahead> <x>som text</x> <s>some text</s> <b>some text</b> <k>some text</k> </aheadtext> <aheadtext> <ahead>second head</ahead> <s>some text</s> <b>some text</b> <k>some text</k> <j>some text</j> </aheadtext> </root>
$t->parse($content); @sib = $t->get_xpath('//ahead', 0)->next_siblings();
I got all siblings in @sib including second ahead and its data. How to add the condition in next_siblings() to get the first ahead contents only?
Thanks,
Aakikce
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Twig - extracting some tags from siblings
by mirod (Canon) on Jun 05, 2007 at 12:36 UTC | |
by aakikce (Acolyte) on Jun 05, 2007 at 14:57 UTC | |
by mirod (Canon) on Jun 05, 2007 at 15:34 UTC |