<?php
$str = '<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><Body><Fault><Code><Value>SOAP-ENV:Receiver</Value></Code><Reason><Text>OMS login failure: Problem in OMS UAMS login -
Nested Exception/Error:
java.net.ConnectException: Tried all: \'1\' addresses, but could not connect over HTTP to server: \'nlut02hr\', port: \'40100\'
</Text></Reason><Role>BEA</Role><Detail><error xmlns:bsl="http://com.amdocs.bss.bsl/"><errorCode>BSL-14002</errorCode><errorMessage>Generic exception returned from external system</errorMessage><detail><fault xmlns:con="http://www.bea.com/wli/sb/context"><errorCode>BEA-380000</errorCode><location><node>getAddOnsRouteNode</node><path>response-pipeline</path></location></fault></detail></error></Detail></Fault></Body></Envelope>'
;
$xml = new SimpleXMLElement($str);
foreach ($xml->getNamespaces(true) as $ns => $uri) {
$str = str_replace(sprintf('%s:', $ns), '', $str);
}
$xml = new SimpleXMLElement($str);
var_dump(objectToArray($xml));
function objectToArray($data) {
if (is_object($data)) {
$data = get_object_vars($data);
}
if (is_array($data)) {
return array_map('objectToArray', $data); } else {
return $data;
}
}
- Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- array(1) {
["Body"]=>
array(1) {
["Fault"]=>
array(4) {
["Code"]=>
array(1) {
["Value"]=>
string(17) "SOAP-ENV:Receiver"
}
["Reason"]=>
array(1) {
["Text"]=>
string(201) "OMS login failure: Problem in OMS UAMS login -
Nested Exception/Error:
java.net.ConnectException: Tried all: '1' addresses, but could not connect over HTTP to server: 'nlut02hr', port: '40100'
"
}
["Role"]=>
string(3) "BEA"
["Detail"]=>
array(1) {
["error"]=>
array(3) {
["errorCode"]=>
string(9) "BSL-14002"
["errorMessage"]=>
string(47) "Generic exception returned from external system"
["detail"]=>
array(1) {
["fault"]=>
array(2) {
["errorCode"]=>
string(10) "BEA-380000"
["location"]=>
array(2) {
["node"]=>
string(18) "getAddOnsRouteNode"
["path"]=>
string(17) "response-pipeline"
}
}
}
}
}
}
}
}
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
- Fatal error: Call to undefined method SimpleXMLElement::getNamespaces() in /in/sgsY5 on line 9
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
- Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/sgsY5 on line 8
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/sgsY5 on line 8
preferences:
285.13 ms | 401 KiB | 378 Q