What are the potential pitfalls of having XML code in a single line?

Having XML code in a single line can make it difficult to read and maintain the code, as it lacks proper formatting and structure. To solve this issue, you can use PHP's SimpleXMLElement class to load the XML data and then use the asXML() method to output the formatted XML.

$xmlString = "<root><element1>Value 1</element1><element2>Value 2</element2></root>";
$xml = new SimpleXMLElement($xmlString);
echo $xml->asXML();