What are some common issues with displaying XML in browsers, particularly in PHP?

One common issue with displaying XML in browsers, particularly in PHP, is that the XML may not be formatted properly for easy readability. To solve this, you can use PHP's `header()` function to set the content type to `text/xml` and then use `DOMDocument` to format the XML before outputting it.

<?php
// Sample XML data
$xmlData = "<root><item>Item 1</item><item>Item 2</item></root>";

// Set the content type to text/xml
header('Content-Type: text/xml');

// Create a new DOMDocument
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xmlData);

// Output the formatted XML
echo $dom->saveXML();
?>