Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: XML Manipulation

by mirod (Canon)
on Nov 19, 2010 at 20:03 UTC ( #872584=note: print w/replies, xml ) Need Help??

in reply to XML Manipulation

How complex are those XPath expression? If they are simple and do not require backtracking, then XML::Twig is ideal for it: set the twig_roots option to a hash <xpath> => 1, then use the twig_print_outside_roots option to output the rest of the XML. See "Building an XML filter" in the docs for an example of that kind of processing, and "twig_handlers" to see the subset of XPath that you can use in this mode.

Alternatively you can use XML::Twig::XPath, parse the file, then go through you list of XPath expressions, use findnodes to get the hits, and delete them.

Beyond XML::Twig, you could try XML::LibXML, which also supports XPath. it is faster and better maintained than XML::XPath. Processing would be the same as above.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://872584]
[marto]: I'm all for that
[choroba]: Trainspotting without OV is just a half of the movie!
LanX just single handedly stopped Brexit!

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2018-02-19 10:51 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (262 votes). Check out past polls.