I am getting a SimpleXML object back from a server using Guzzle. The response printed as string looks like valid XML. But when I try to get the individual element values, I am getting blank.
Please help me find what the problem is.
My code is here as well as on Viper-7:
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<RespOrderHistory xmlns="http://www.example.com/testService/xsd/OrderHistoryResponse_v1.xsd" xmlns:typ="http://www.example.com/testService/xsd/Types_v1.xsd">
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Cancelled</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Cancelled</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Cancelled</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Cancelled</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Cancelled</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>638</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-08T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-08T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>138</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-07T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-07T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>133</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-07T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-07T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
<OrdersList>
<typ:OrderNumber>128</typ:OrderNumber>
<typ:OrderSubmitDate>2014-04-07T00:00:00.000+05:30</typ:OrderSubmitDate>
<typ:CurrentStatus>Active</typ:CurrentStatus>
<typ:StatusDate>2014-04-07T00:00:00.000+05:30</typ:StatusDate>
</OrdersList>
</RespOrderHistory>';
$sXml = simplexml_load_string ($xml);
foreach($sXml as $order){
echo $order->getName()." ";
print_r($order);
echo "<br/>";
}
?>