PHP Iterating simplexml in foreach loop

scadassarse

New Member
I have a simplexml object which looks as below\[code\]<?xml version="1.0"?><SalesInvoices xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://api.unleashedsoftware.com/version/1"> <SalesInvoice> <OrderNumber>100</OrderNumber> </SalesInvoice> <SalesInvoice> <OrderNumber>101</OrderNumber> </SalesInvoice></SalesInvoices>\[/code\]I want to iterate through it and print only the order number. I use this script:\[code\]foreach ($xml->SalesInvoices->SalesInvoice as $salesinvoice) { echo "hello"; echo $salesinvoice->OrderNumber;}\[/code\]When I do this I get no output from the loop at all, even the "hello" does not print. What am I doing wrong?
 
Back
Top