I am trying to use SimpleXML to output a well-formed XHTML document. I do it like this:
$pbDoc = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>'.$myTitle.'</title>
</head>
</html>');
After creating the document, I want to output some pretty readable code, so I use the DOM module as follows:
$dom = new DOMDocument();
$dom->loadXML($pbDoc->asXML());
$dom->formatOutput = true;
echo $dom->saveXML();
Now there are two strange things that bother me, and I wonder if this behavior is normal and how to disable it, if possible.
Can someone enlighten me about where I can be wrong, and how to get rid of these troubles?