3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <?xml version="1.0" encoding="utf-8"?> <createTransactionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">   <refId>123456</refId>   <messages>     <resultCode>Ok</resultCode>     <message>       <code>I00001</code>       <text>Successful.</text>     </message>   </messages>   <transactionResponse>     <responseCode>1</responseCode>     <authCode>UGELQC</authCode>     <avsResultCode>E</avsResultCode>     <cavvResultCode />     <transId>2148061808</transId>     <refTransID />     <transHash>0B428D8A928AAC61121AF2F6EAC5FF3F</transHash>     <testRequest>0</testRequest>     <accountNumber>XXXX0015</accountNumber>     <accountType>MasterCard</accountType>     <message>       <code>1</code>       <description>This transaction has been approved.</description>     </message>     <userFields>       <userField>         <name>MerchantDefinedFieldName1</name>         <value>MerchantDefinedFieldValue1</value>       </userField>       <userField>         <name>favorite_color</name>         <value>lavender</value>       </userField>     </userFields>   </transactionResponse> </createTransactionResponse> XML; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadXML($xml); libxml_clear_errors(); libxml_use_internal_errors(false); $query = '/m:createTransactionResponse/m:messages/m:resultCode[1]/text()'; $xpath = new DOMXpath($dom); $xpath->registerNamespace('m', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'); var_dump($xpath->query($query)->item(0));
Output for 8.3.0 - 8.3.6
object(DOMText)#3 (23) { ["wholeText"]=> string(2) "Ok" ["data"]=> string(2) "Ok" ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> NULL ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) "Ok" ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> NULL ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) "Ok" }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
object(DOMText)#3 (21) { ["wholeText"]=> string(2) "Ok" ["data"]=> string(2) "Ok" ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> NULL ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) "Ok" ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) "Ok" }
Output for 7.3.16 - 7.3.33, 7.4.4 - 7.4.33
object(DOMText)#3 (19) { ["wholeText"]=> string(2) "Ok" ["data"]=> string(2) "Ok" ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) "Ok" ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) "Ok" }
Output for 7.0.20, 7.1.5 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.1, 7.4.0 - 7.4.3
object(DOMText)#3 (19) { ["wholeText"]=> string(2) "Ok" ["data"]=> string(2) "Ok" ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) "Ok" ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) "Ok" }
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.14, 7.1.0
object(DOMText)#3 (18) { ["wholeText"]=> string(2) "Ok" ["data"]=> string(2) "Ok" ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) "Ok" ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) "Ok" }
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.10, 5.4.0
object(DOMText)#3 (0) { }
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function libxml_use_internal_errors() in /in/s5VDd on line 46
Process exited with code 255.
Output for 4.4.3 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/s5VDd on line 54
Process exited with code 255.
Output for 4.4.2
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/s5VDd on line 55
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/s5VDd on line 54
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/s5VDd on line 54
Process exited with code 255.

preferences:
223.29 ms | 401 KiB | 327 Q