PHP-SharePoint-Lists-API
PHP-SharePoint-Lists-API copied to clipboard
Handling Microsoft's invalid XML responses / "Looks like we got no XML document" error
Certain responses from the SharePoint API return invalid XML, an example is when SharePoint returns anything with 
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 "" 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:
- http://stackoverflow.com/questions/3865689/how-to-transform-source-with-invalid-xml-characters
- https://blogs.technet.microsoft.com/stefan_gossner/2009/08/26/how-to-deal-with-invalid-characters-in-soap-responses-from-asp-net-web-services/
- http://blog.cwa.me.uk/2007/10/01/invalid-xml-from-a-net-web-service/
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 )