Question

What is the difference between XML::LibXML , XML::DOM and XML::SAX. Can I use XML::LibXML only which should provide all the functionalities of XML::DOM and XML::SAX

Was it helpful?

Solution

XML::SAX is a framework to implement SAX parsers. It comes with XML::SAX::PurePerl which is a pure-Perl implementation but other XML modules can provide their own implementations sharing the same high-level API. One such module is XML::LibXML. An XML::SAX parser based on XML::LibXML will typically be faster than a pure-Perl solution.

XML::DOM is a module that provides a DOM Level 1 compliant XML manipulation API on top of XML::Parser which in turn is based on the expat C library. XML::LibXML is based on libxml2 and provides its own implementation of the DOM interface (a large subset of DOM Level 3). So it should provide all of the functionality of XML::DOM.

To summarize, you can use only XML::LibXML for XML processing but XML::SAX is a dependency. If you use the XML::LibXML SAX parser, XML::SAX will be used behind the scenes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top