<po-response xsi:schemaLocation="http://seller.xxxxxxx.xxx.com/xx/xx https://seller.xxxxxxx.xxx.com/xx/xx-v2.xsd"> − <purchase-order> <po-number>55555</po-number> <po-date>2011-01-27</po-date> <expected-ship-date>2011-01-31</expected-ship-date> − <shipping-detail> <ship-to-name>John Smith</ship-to-name> <address>123 SUNRISE AVE NY</address> <city>NEW YORK</city> <state>NY</state> <zipcode>98311</zipcode> <phone>11111111</phone> <shipping-method>Ground</shipping-method> </shipping-detail> <customer-name>John Smith</customer-name> − <po-line> − <po-line-header> <line-number>1</line-number> <item-id>cC-W2W61</item-id> <item-name>Fabric - XXXXXX</item-name> <item-sell-price>14.99</item-sell-price> <order-quantity>1</order-quantity> </po-line-header> − <po-line-detail> <po-line-status>NEW</po-line-status> <quantity>1</quantity> Code (markup): Can you please help me in reading values from this XML file I am trying using following code. $str = "https://www.example.com/xml/"; $output = file_get_contents($str); $xmlOBJ = simplexml_load_string($output); $ord_no = (string) $xmlOBJ->purchase-order->po-number; PHP: getting this error syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' Can you please help me getting vaule "55555"
It should be $ord_no = (string) $xmlOBJ->{"purchase-order"}->{"po-number"}; PHP: you cannot use sign "-" in property name.