Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: XML-Twig: more efficient tree processing

by sundialsvc4 (Abbot)
on Aug 08, 2012 at 03:03 UTC ( #986119=note: print w/ replies, xml ) Need Help??


in reply to XML-Twig: more efficient tree processing

If the XML tree is large, and you find yourself writing a lot of logic to search through it ... I ... very(!) cautiously ... wonder if you should in fact be using XML::LibXML and using XPath expressions rather than Perl logic to navigate through the tree?


Comment on Re: XML-Twig: more efficient tree processing
Re^2: XML-Twig: more efficient tree processing
by Anonymous Monk on Aug 08, 2012 at 03:06 UTC

    So instead of using minimal memory with the already written XML::Twig , he should load the giant tree into memory and rewrite the program to use xpath1?

    That don't make sense

      An algorithm that is already started with XML::Twig probably cannot be changed now.   There are two purposes for using other strategies ... to keep large structures out of memory, and to avoid the necessity of procedural logic within the Perl program to traverse them.

        An algorithm that is already started with XML::Twig probably cannot be changed now

        That is what I said

Re^2: XML-Twig: more efficient tree processing
by ambrus (Abbot) on Aug 08, 2012 at 21:17 UTC

    IMO, if you want incremental parsing with callbacks because your tree does not fit in the memory, XML::LibXML is much harder to use than XML::Twig.

      Yup, its quite laborious, pretty much like using raw XML::Parser (or HTML::Parser)

      Where as in Twig you'd say I only want trees out of '/foo/bar/bar' with LibXML (like XML::Parser) you have to build those trees yourself with XML::LibXML::SAX::Parser -- although, there is no reason a XML::Twig type API couldn't be built on top of XML::LibXML::SAX::Parser, its just extra work, given that Twig already exists :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986119]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-09-19 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (145 votes), past polls