What are some potential pitfalls when working with namespaces in SimpleXML?

When working with namespaces in SimpleXML, a potential pitfall is not correctly handling namespaces when accessing elements or attributes. To avoid issues, it is important to use the `->children()` method to access elements within a namespace and the `->attributes()` method to access attributes within a namespace.

// Load XML file
$xml = simplexml_load_file('file.xml');

// Define namespace
$ns = $xml->getNamespaces(true)['ns'];

// Access elements within namespace
$elements = $xml->children($ns)->element;

// Access attributes within namespace
$attributes = $xml->children($ns)->element->attributes();