How can SimpleXML be used to parse XML with namespaces in PHP?

When parsing XML with namespaces in PHP using SimpleXML, you need to register the namespaces before accessing elements with those namespaces. This can be done by using the `registerXPathNamespace()` method to map the namespace prefixes to the actual URIs. Once the namespaces are registered, you can use XPath expressions with the prefixes to access elements within those namespaces.

$xml = <<<XML
<root xmlns:ns="http://example.com/ns">
    <ns:element>Value</ns:element>
</root>
XML;

$doc = simplexml_load_string($xml);

$doc->registerXPathNamespace('ns', 'http://example.com/ns');
$elements = $doc->xpath('//ns:element');

foreach ($elements as $element) {
    echo $element . PHP_EOL;
}