$results = $xpath->query( '//div[@class="reports"]/div[@class="ERROR"]/div[@class="author"]' );
foreach ($results as $node)
{
echo $node->nodeValue;
}
$results = $xpath->query( '//div[@class="reports"]/div[@class="SUCCESS"]/div[@class="name"]' );
foreach ($results as $node)
{
echo $node->nodeValue;
}
$results = $xpath->query( '//div[@class="reports"]/div' );
foreach ($results as $node)
{
$class=($node->getAttribute('class')==='SUCCESS') ? 'name' : 'author';
foreach ($node->childNodes as $child)
{
if ($child->nodeName=='div' && $child->getAttribute('class')===$class)
{
echo $child->nodeValue;
break;
}
}
}