DISCLAIMER: Do not use this feature, if you don’t really know what you do. Fixing the other side and rejecting the document are almost always the better options than using this feature. And above all Do not set this property by default. But there are circumstances where this feature can be useful, and that’s the reason why I enabled it.
See also the comments and follow up post for more discussion. (Disclaimer added 20 August 2004)
I just commited a patch to the 5.1 branch of PHP, which allows you to parse not well-formed XML documents and adds the missing elements, eg. missing closing tags.
This can be very useful, if you have to parse XML documents, on which you don’t have any influence. Of course libxml2 just has to guess, what’s wrong, so it’s not always perfect, but for simple errors it’s certainly good enough.
To use this feature, you just have to set the DomDocument property recover to true before loading the XML document and then loading the XML document will always return something more or less useful:
$xml = new DomDocument();
which will return (besides a bunch of errors, which still will show up):