What are some common pitfalls when using regular expressions to parse XML in PHP?

One common pitfall when using regular expressions to parse XML in PHP is that XML is a complex and hierarchical data structure that regular expressions are not well-suited to handle. It is recommended to use PHP's built-in XML parsing functions, such as SimpleXML or DOMDocument, which are specifically designed for parsing XML data and are more reliable and efficient.

// Example using SimpleXML to parse XML data
$xmlString = '<root><item>Value 1</item><item>Value 2</item></root>';
$xml = simplexml_load_string($xmlString);

foreach ($xml->item as $item) {
    echo $item . "\n";
}