3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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="http://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(); $dom->loadXML($xml); $query = 'm:messages/m:message'; $xpath = new DOMXpath($dom); $xpath->registerNamespace('m', 'http://AnetApi/xml/v1/schema/AnetApiSchema.xsd'); var_dump($xpath->query($query)->length);
based on VtGNc
Output for 5.0.0 - 5.1.1, 5.1.3 - 7.1.0
Warning: DOMDocument::loadXML(): attributes construct error in Entity, line: 2 in /in/0dVgM on line 45 Warning: DOMDocument::loadXML(): Couldn't find end of Start Tag createTransactionResponse line 2 in Entity, line: 2 in /in/0dVgM on line 45 Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 2 in /in/0dVgM on line 45 int(0)
Output for 5.1.2
Warning: DOMDocument::loadXML(): attributes construct error in Entity, line: 2 in /in/0dVgM on line 46 Warning: DOMDocument::loadXML(): Couldn't find end of Start Tag createTransactionResponse line 2 in Entity, line: 2 in /in/0dVgM on line 46 Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 2 in /in/0dVgM on line 46 int(0)
Output for 4.4.3 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/0dVgM on line 50
Process exited with code 255.
Output for 4.4.2
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/0dVgM on line 51
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/0dVgM on line 50
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/0dVgM on line 50
Process exited with code 255.