ifacethoughts

XML Pull Parsing Using PHP 5

XML Pull Parsing is seen as one of the most efficient ways of parsing big documents, especially when the entire document has to be parsed. It has been pretty active in the Java world and in relatively newer languages like C#. For pull parsing the parser should be able to operate in streaming mode. It should not read the entire document in memory, that DOM does, and it should not push content to the client, that SAX does. It should answer when the client queries - the client should be able to pull rather than get the content pushed on it.

Pull parsing has not been very popular in PHP. Elliotte Rusty Harold illustrates pull parsing XML using the XMLReader class inbuilt in PHP 5.

PHP 5 introduced XMLReader, a new class for reading Extensible Markup Language (XML). Unlike SimpleXML or the Document Object Model (DOM), XMLReader operates in streaming mode. That is, it reads the document from start to finish. You can begin to work with the content at the beginning before you see the content at the end. This makes it very fast, very efficient, and very parsimonious with memory. The larger the documents you need to process, the more important this is.

If you see yourself parsing large XML documents in your project, PHP 5 now has an inbuilt solution.

Discussion [Participate or Link]

  1. XML Parsing With PHP 5 on iface thoughts said:

    [...] PHP 5 also introduces a class called XMLReader that operates in stream mode and lets you do pull parsing. Pull parsing lets the client pull data from the XML document whenever required, which is perfect [...]

  2. Adoption Of PHP 5 | iface thoughts said:

    [...] the new technologies. PHP 5 has some good features, especially in working with XML and enabling pull parsing. Maybe a transition phase can help, where these tools support both the older and newer versions. [...]

Say your thought!

Who are you?

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

freshcomments

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
Y!: anadgouda
GTalk: anadgouda@gmail.com
MSN: anadgouda@hotmail.com
Skype: anadgouda
My bookmarks

currentproject

Complete Wellbeing

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.

Twitter - Using Envy Code R and liking it. Thank you Damien. http://tinyurl.com/688mft