Forum Moderators: coopster

Message Too Old, No Replies

simple xml

         

optik

11:17 am on Jun 21, 2011 (gmt 0)

10+ Year Member



Hi I want to use simplexml_load_string() to access data in the string below, how would I get to the part:

"?valid=true&trans_id=TRAN0001&code=A&auth_code=9999&amount=50.0&test_status=true &mpi_status_code=212&mpi_message=Cardholder Not Participating"



<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body> <ns1: threeDSecureEnrolmentRequestResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="SECCardService"> <ns1: threeDSecureEnrolmentRequestReturn
xsi:type="xsd:string">?valid=true&trans_id=TRAN0001&code=A&auth_code=9999&amount=50.0&test_status=true &mpi_status_code=212&mpi_message=Cardholder Not Participating</ns1: threeDSecureEnrolmentRequestReturn>
</ns1: threeDSecureEnrolmentRequestResponse> </soapenv:Body>
</soapenv:Envelope>

coopster

2:27 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The SimpleXML examples show you how to navigate the structure. Review a few of them and see if that gets you started ...
[php.net...]

penders

4:02 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You actually get errors if you try to load that XML directly with
simplexml_load_string()
. According to the comments [uk3.php.net], "SimpleXML does not correctly parse SOAP XML results if the result comes back with colons ‘:’ in a tag, like <soap:Envelope>.". Instructions are given in that comment to preg_replace() the colons prior to parsing with SimpleXML. (Although the regex given doesn't work for me on your example.)

optik

10:05 am on Jun 22, 2011 (gmt 0)

10+ Year Member



Ok thanks I knew about normal xml was just this SOAP format.