<?php
$content = '
<a>
<d>
<b>
<c/><c/>
</b>
</d>
<b>
<c/><c/><c/>
</b>
<b>
<c/>
</b>
</a>';
$content = '
<a>
<b>
<c/><c/>
</b>
<b>
<c/><c/><c/>
</b>
<b>
<c/>
</b>
</a>';
$xml = new DOMDocument();
$xml->loadXML($content);
$xpath = new DOMXPath($xml);
$result = $xpath->query('//b[1]//c');
echo $result->length;
?>
Why is it that the first $content gives a different answer than the
second $content? Shouldn't they both be the same? Shouldn't they
both be 2? What I'm getting, instead, is that the former gives me 5
and the latter, 2. Which doesn't make any sense to me.
Any ideas?