What are the best practices for displaying XML data in HTML using PHP?

When displaying XML data in HTML using PHP, it is important to properly parse the XML data and then format it in a readable way for the user. One common approach is to use PHP's SimpleXML extension to parse the XML data and then loop through the elements to display them in a structured format within HTML.

<?php
$xmlString = '<data><item>Item 1</item><item>Item 2</item><item>Item 3</item></data>';
$xml = simplexml_load_string($xmlString);

echo '<ul>';
foreach ($xml->children() as $item) {
    echo '<li>' . $item . '</li>';
}
echo '</ul>';
?>