Below is the XML response you get from the W3C Validation API:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<m:markupvalidationresponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:m="http://www.w3.org/2005/10/markup-validator">
<m:uri>http://www.pritaeas.net/</m:uri>
<m:checkedby>http://validator.w3.org/</m:checkedby>
<m:doctype>-//W3C//DTD XHTML 1.1//EN</m:doctype>
<m:charset>utf-8</m:charset>
<m:validity>true</m:validity>
<m:errors>
<m:errorcount>3</m:errorcount>
<m:errorlist>
<m:error>
<m:line>10</m:line>
<m:col>1</m:col>
</m:error>
<m:error>
<m:line>12</m:line>
<m:col>2</m:col>
</m:error>
<m:error>
<m:line>14</m:line>
<m:col>3</m:col>
</m:error>
</m:errorlist>
</m:errors>
<m:warnings>
<m:warningcount>0</m:warningcount>
<m:warninglist>
</m:warninglist>
</m:warnings>
</m:markupvalidationresponse>
</env:Body>
</env:Envelope>
I've tried the following code to obtain a list of error nodes, but something is wrong or missing. The length is always reported as zero, so no elements in the list.
$doc = new DOMDocument();
$doc->loadXML(file_get_contents('check.xml'));
$xpath = new DOMXPath($doc);
$xpath->registerNamespace('m', 'http://www.w3.org/2005/10/markup-validator');
$nodelist = $xpath->query('error');
print_r($nodelist);
echo '<br/>Length: ' . $nodelist->length;
Hopefully someone can enlighten me.