use XML::LibXML; my $string = q| Child 1 Child 2 Child 3 |; 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