What are the common pitfalls when passing links via XML in PHP?

One common pitfall when passing links via XML in PHP is not properly encoding the URLs. This can lead to invalid XML structure and cause parsing errors. To solve this issue, you should use the `htmlspecialchars()` function to encode the URLs before inserting them into the XML document.

// Encode the URL before passing it in XML
$url = 'https://example.com/page';
$encodedUrl = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');

$xml = new SimpleXMLElement('<xml></xml>');
$link = $xml->addChild('link', $encodedUrl);

echo $xml->asXML();