thybag / PHP-SharePoint-Lists-API

A simple PHP API to make working with SharePoint lists easy.
MIT License
184 stars 95 forks source link

Handling Microsoft's invalid XML responses / "Looks like we got no XML document" error #91

Open hi2u opened 8 years ago

hi2u commented 8 years ago

Certain responses from the SharePoint API return invalid XML, an example is when SharePoint returns anything with &#1 it in. It breaks the XML parser in PHP and produces the error:

Error (Client) looks like we got no XML document

Parsing the XML response directly in any other (non-microsoft) XML parser confirms that Microsoft is returning invalid XML...

www.xmlvalidation.com says:

Character reference "&#1" is an invalid XML character.

The Linux command line program xmllint says:

parser error : xmlParseCharRef: invalid xmlChar value 1

   ^

Is there some work-around or cleanup we can do in Microsoft's response XML to avoid the XML parser breaking? Or make the PHP XML parser more tolerant of Microsoft's invalid XML?

Apparently Microsoft have known that their XML responses are invalid for years, so in line with their usual approach to cross-platform compatibility... they're not going to fix it.

Some possibly relevant links:

thybag commented 8 years ago

Hmm, wasn't aware of that one. Sounds about right for SP though :P

I suspect I could probably work around it by extending the php SoapClient to run some additional filtering (as you suggested) as part of it curling the webservices (kinda like how the ntlm auth stuff works https://github.com/thybag/PHP-SharePoint-Lists-API/blob/develop/src/Thybag/Auth/SoapClientAuth.php#L84 )