in reply to XML dont include parent node
use warnings; use strict; use XML::Twig; my $xml=<<'XML'; <Root> <Parent> <child1>Child 1</child1> <child2>Child 2</child2> <child3>Child 3</child3> <ufo> Ufo there!</ufo> </Parent> </Root> XML my $twig= new XML::Twig( pretty_print => 'indented', twig_handlers => { '/Root/Parent/*' => \&fie +ld }, ); $twig->parse( $xml); sub field { my( $twig, $field)= @_; return unless $field->gi() =~ /^child/i; $field->print; #OR print $field->text(); } #OUTPUT # # <child1>Child 1</child1> # <child2>Child 2</child2> # <child3>Child 3</child3>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML dont include parent node
by Anonymous Monk on Dec 11, 2013 at 09:50 UTC | |
by Discipulus (Canon) on Dec 11, 2013 at 12:49 UTC |