in reply to Re: Re: XML Module Recommendations
in thread XML Module Recommendations

The DOM is still dangerous when extracting information,unless tou are very cautious. The main problem is with navigation methods, like getFirstChild: you just cannot use it without wrapping it into your own method. The first child of an element can be a lot of unexpected things: the line return after the element start tag, a comment, a processing instruction...and maybe even the next element. The addition of XPath in XML::LibXML makes it much safer by letting you do $elt->findnodes( 'people') which gives you the list of people elements child of $elt.

As for differenciating between tags with the same name but in different contexts, XML modules will give you access to the context stack, so it will not be a problem. For example in Twig you can have handlers on website/name or on people/name, in XML::LibXML you would similarly use XPath to get the elements you want.

In fact the XML equivalent of SQL is XPath (at least within a single document, XML Query deals with collections of documents). A nice resource for XML-related tutorials is Zvon.org, they have a good XPath tutorial.

XML::Twig is purely perl. Note that if you don't want to use Perl you can always use XSLT, there are plenty of XSLT processors around, some of which can even be called from Perl.

One last question, especially in light of a recent thread: it seems to me that you are dealing with data, and doing the kind of processing that a database doesvery well. So why are you using XML at all? Couldn't you just model your data into tables and use a DB? There are several portable alternatives that support the kind of processing you seem to be looking for.

Replies are listed 'Best First'.
Re: Re: Re: Re: XML Module Recommendations
by Anonymous Monk on Jan 27, 2003 at 07:25 UTC
    it seems to me that you are dealing with data, and doing the kind of processing that a database doesvery well. So why are you using XML at all? Couldn't you just model your data into tables and use a DB? There are several portable alternatives that support the kind of processing you seem to be looking for.

    I would, but the code needs to be run on many different systems and while I can ensure Perl is installed, I would have a lot of trouble ensuring my database of choice would be.

    Thanks for all the suggestions though, I should be able to find something appropriate now :)

      Have you seen DBD::SQLite yet? It's not just a driver, but a self contained database engine (based on the SQLite library) that doesn't require a daemon at all.

      Makeshifts last the longest.

        Sounds cool, I'll check it out. Thanks! :)