in reply to Re: Extract Data from XML (unique xml format?)
in thread Extract Data from XML (unique xml format?)

use XML::LibXML; my $string = q| <Root> <Parent> <child1>Child 1</child1> <child2>Child 2</child2> <child3>Child 3</child3> </Parent> </Root>|; my $doc = XML::LibXML->load_xml(string => $string); my @nodes = $doc->findnodes('//Parent'); for my $node (@nodes) { my @childnodes = $node->childNodes or next; for my $cnode (@childnodes) { if ($cnode->nodeName =~ m/^child/) { print 'name: '. $cnode->nodeName . ', '; print 'content: '. $cnode->textContent ."\n"; } } } # Output: # name: child1, content: Child 1 # name: child2, content: Child 2 # name: child3, content: Child 3

Replies are listed 'Best First'.
Re^3: Extract Data from XML (unique xml format?)
by clapeters (Initiate) on Jun 23, 2015 at 16:24 UTC

    This works as well AjitKhodke. Again, I so appreciate your help and responses from all.