Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

BitFlux Blog:
Parsing Bad XML in PHP 5.1
Aug 19, 2004 @ 13:15:16

In a new note from the BitFlux blog, Christian Stocker has information about the latest patch comitted to the PHP 5.1 branch that allows you to parse not well-formed XML documents and adds the missing elements, eg. missing closing tags.

Basically, it sets up the document with the DOM parser using a special variable (recover) to tell the interpreter to ignore incomplete data/tags and still make the information inside the document useable. The output isn't the normal object/data model that the DomDocument normally contains, but instead outputs a corrected XML document to take and parse all over again.

With all of the badly formatted XML out there, something like this, can come in very, very handy...

tagged:

Link:


Trending Topics: