http://www.perlmonks.org?node_id=998680


in reply to XML::Simple XML / XMLin / XMLout? or something else?

XML::Simple is almost certainly not what you want to be using. Here's an example using XML::LibXML...

use XML::LibXML 1.70; my $xml = XML::LibXML->load_xml(IO => \*DATA); foreach my $book ($xml->getElementsByTagName('book')) { print "GOT THIS: " . $book->toString . "\n"; } __DATA__ <booklist> <book> <author>Book 1 author 1</author> <author>Book 1 author 2</author> <title>Book 1 title</title> <isbn>Book1ISBN</isbn> </book> <book> <author>Book 2 author 1</author> <author>Book 2 author 2</author> <title>Book 2 title</title> <isbn>Book2ISBN</isbn> </book> <book> <author>Book 3 author 1</author> <author>Book 3 author 2</author> <author>Book 3 author 3</author> <title>Book 3 title</title> <isbn>Book3ISBN</isbn> </book> </booklist>
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'