What are some common pitfalls when using SimpleXML in PHP for parsing and manipulating XML files?

One common pitfall when using SimpleXML in PHP for parsing and manipulating XML files is not properly handling namespaces. If the XML file contains namespaces, you need to use the `->children()` method to access elements within those namespaces. Another pitfall is not checking for errors when loading the XML file, which can lead to unexpected behavior.

// Load the XML file and handle errors
$xml = simplexml_load_file('file.xml');
if ($xml === false) {
    die('Error loading XML file');
}

// Access elements within namespaces using the ->children() method
$ns = $xml->children('http://example.com/namespace');
$element = $ns->childElement;