This is my code:
$response = Http::withHeaders([
"Content-Type" => "application/xml",
"User-Agent" => "Insomnia/2023.5.6",
"Accept" => "application/xml"
])->withBody($xml, 'application/xml')->post($url);
if (!$response->successful()) {
Log::error($response);
return 0;
}
$xmlObject = simplexml_load_string($response->body());
$body = $xmlObject->children('SOAP-ENV', true)->Body;
$response = $body->children('ns1', true)->StoreProductsResponse;
$return = $response->return;
$namespaces = $xmlObject->getNamespaces(true);
If I do a Log::info($response->body()), the following string appears:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://catalog.nexsysla.com/"><SOAP-ENV:Body><ns1:StoreProductsResponse><return><mark>3nStar</mark><parent>POS</parent><category>Cash Drawers</category><sku>CD250</sku><name>CD250</name><price>48</price><currency>USD</currency><tax_excluded>19</tax_excluded><inventory>4</inventory><short_description>3nStar CD250, Manual & automatic cash drawer, Steel, Black, 330 mm, 343 mm, 90 mm</short_description><long_description>The Cash Drawer CD250 is the ideal choice for businesses needing a compact, heavy duty solution. Available as small as 330mm x 343mm x 90mm, the CD250 is small enough to be used in mobile payment stations such as kiosks or food vendor carts. The cash drawer uses a quick disconnect cable to interface with most major receipt printers, making installation a snap.</long_description>
That is just an example of product information, in xml format. But, the problem is that when I do a Log::info( $xmlObject) after I converted that string to xml with simplexml_load_string, the variable $xmlObject appears empty
And no error appears, or anything. Only the variable appears empty