I have a php page that parses some xml text. That text comes from user input in a html textfield.
Whenever there is any whitespace at all between nodes, the Domdocument xml parser fails to parse the document correctly. Essentially it will recognize the first node, but any nested nodes it cannot find.
Removing the whitespace, it works no problem.
$xmldoc = new DOMDocument();
$xmldoc->loadXML($rawxml);
$top = $xmldoc->documentElement;
if(!$top) {echo "error: xml config is empty"; exit(-1);}
if($top->nodeName != "config") die("error: expect config tag as first element");
$nameNode = $top->childNodes->item(0);
//Fails here
if($nameNode->nodeName != "name") die("error: expect name tag following config tag");
Works
<config><name>sdf2</name></config>
Does not work
<config> <name>sdf2</name></config>