SimpleXML is not working with xml response from external api

And according to your output

SimpleXMLElement Object
(
    [Inventory] => SimpleXMLElement Object
        (
            [Product] => TestProduct
            [ProductInventories] => SimpleXMLElement Object
                (
                    [ProductInventory] => SimpleXMLElement Object
                        (
                            [Site] => 101
                            [QuantityInStock] => 238.00000
                            [QuantityHardAllocated] => 0.00000
                            [QuantitySoftAllocated] => 0.00000
                        )

                )

        )

)

You have to access your variable inside object parsed from this XML as:

$QtyInStock_xml  = $xml_parsed_obj->Inventory->ProductInventories->ProductInventory->QuantityInStock;

Just because XML is case sensitive ! and object’s keys in PHP are case sensitive too.

Overall keep in mind that PHP’s variables are case sensitive.

If to dig deeper function names are non case sensitive, but never rely on it! forget about it and never disrespect function’s name case !

Just accept it as a rule that whatever code you type, either it’s a variable or function – treat everything as case sensitive and may the good code be with you 🙂