What is the correct way to access attribute values in SimpleXML in PHP?

When working with SimpleXML in PHP, to access attribute values, you need to use the arrow notation "->" followed by the attribute name within square brackets. This allows you to retrieve the value of a specific attribute within an XML element.

$xml = simplexml_load_string($xmlString);
$attributeValue = $xml->elementName['attributeName'];