Hiya, I am trying to parse a response XML SOAP message with SimpleXML and building up the XML tree, but every SOAP message fails even, that the XML format is valid! After a couple of times trying, just ended up with googleing the issue and finding out: SimpleXML has problems with the namespaces, prefixes. Does anyone know a way around without actually touching too much the SOAP structure? I have seen couple of solutions, but it assumes to slightly change the SOAP data after receiving it. Also it seems, that SimpleXML cannot read XML attributes, ie: <Person sex="male">Robert Green</Person> SimpleXML will build up the XML structure without the sex="male" attribute, which is lost. There are reasons and situations when these attributes are important, so would be nice if PHP could address these issues, esepcially parsing SOAP messages with namespaces. Thanks for anyone to share any knowledge on these issues.
I found your post googling for my SOAP problem. But I want to chime in and say you are on crack. Just do $xml->Element['sex'] It's in the wonderful PHP docs. Now, tell me how to fix the problem i have wtih these goddamn stdClass objects! ahh!
got it work after all. SimpleXML does indeed support attribute reading from XML, so my initial thought thet <Person sex="male"> wont be recognised was false. Secondly the SOAP namespace problem can be sorted out, just take a look here: http://dd32.id.au/2007/09/29/php-simplexml-soap/ I used the str_replace() function to replace the soap:Body tag with an empty string and it works for me.