What are some common pitfalls when using XPath to parse XML files in PHP?

One common pitfall when using XPath to parse XML files in PHP is not properly registering the XML namespace. This can result in XPath queries not returning the expected results. To solve this issue, make sure to register the XML namespace using the `registerXPathNamespace` method before executing XPath queries.

$xml = new DOMDocument();
$xml->load('file.xml');

$xpath = new DOMXPath($xml);
$xpath->registerNamespace('ns', 'http://www.example.com/namespace');

$query = '//ns:element';
$elements = $xpath->query($query);

foreach ($elements as $element) {
    // Process elements
}