Are there any alternative methods to retrieve attributes from a SOAP response in PHP?

When working with SOAP responses in PHP, one common method to retrieve attributes is by using the SimpleXMLElement class and XPath queries. However, an alternative method is to use the DOMDocument class to parse the SOAP response and retrieve the attributes directly.

// Load the SOAP response into a DOMDocument
$response = new DOMDocument();
$response->loadXML($soapResponse);

// Use DOMXPath to query for the desired attribute
$xpath = new DOMXPath($response);
$attributeValue = $xpath->query('//namespace:element/@attributeName')->item(0)->nodeValue;

// Output the attribute value
echo $attributeValue;