The firstChild
will select a child <colgroup>
which is empty.
I think you want to replace
$result[] = $spans->item($i)->firstChild->nodeValue;
by
$result[] = $spans->item($i)->nodeValue;
This currently returns
Not Found(0) / Transporting(0) / Pick Up(0) / Delivered(0)
If you want to descend into this string even further you can take advantage of the fact that the status values "(0)"
are braced in <em>
tags. So, for example changing yout XPATH expression to
$query = "//*[contains(concat(' ', normalize-space(@class), ' '), ' $classname ')]//em";
will select the individual status and put them into the array result
. Using the index 0..3
you will be able to randomly access the status. If you want to have a numeric value you will still have to extract it from the string.