Had some trouble looking this one up online, finally cracked it though …
$doc = new DOMDocument('1.0');
$doc->loadXML("<root><test>Hello World!</test></root>");
$rootNode = $doc->documentElement;
… simple enough in hindsight. Just a had trouble finding documentElement in the manual!
Advertisement