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


in reply to Using Expat: how to extranct and manipulate elements?

For this particular task, I'd look at the XML::XPath modules. XPath allows you to search through a tree and find the nodes you need. The way I understand it, XPath is to XML trees as regular expressions are to strings. The XPath syntax is not very hard to figure out. You can read the specs here.

Here is an example from the XML::XPath docs

use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new(filename => 'test.xhtml'); my $nodeset = $xp->find('/html/body/p'); # find all paragraphs foreach my $node ($nodeset->get_nodelist) { print "FOUND\n\n", XML::XPath::XMLParser::as_string($node), "\n\n"; }

I think XPath is really interesting stuff and if you post some of the xml you are dissecting, I'll try to help you out as best I can.

You might also want to give the perl-xml mailing list a quick search.

Get Strong Together!!