I'm using an XPath query to find attribute values. However, I want to go through each div and if the attributes are not found, return nothing. Is there a way to do this?
HTML:
<div id="a" class="a">text</div>
<div>text</div>
<div id="b" class="b">text</div>
XPath:
$values = $XPath->query('//div/@id | //div/@class');
Result:
array('a', 'a', 'b', 'b');
Desired Result:
array('a', 'a', '', '', 'b', 'b');
As of now, I'm kind of in XPath already, and I would like to stay in this direction for right now.