easy dom creation using LibXML?

Robin Berjon robin.berjon at expway.fr
Thu Jan 12 16:20:38 GMT 2006


On Jan 12, 2006, at 17:08, Michel Rodriguez wrote:
> Robin Berjon wrote:
>> Or you could even go into full heresy mode: using the Twig  
>> helpers  you like, generate SAX output from the resulting twig,  
>> and feed that  to XML::LibXML. It could probably be easy to  
>> encapsulate, and as an  added bonus you'd have the satisfaction of  
>> making Michel cringe every  time you run your program :)
>
> Can XML::LibXML do this? That would be cool actually.

Of course! The whole point of SAX is to get modules to interoperate  
-- a self-respecting module that represents an XML tree should really  
therefore support SAX input and output. XML::LibXML does this through  
its ::SAX::Builder class:

   http://search.cpan.org/~phish/XML-LibXML-1.58/lib/XML/LibXML/SAX/ 
Builder.pod

It's not exactly over documented, but it works just like any other  
SAX handler. What end_document() returns (which is whatever is  
returned by the method that calls it) is the constructed DOM.

-- 
Robin Berjon
    Senior Research Scientist
    Expway, http://expway.com/





More information about the london.pm mailing list