XML is like
value1 value2
I want to write XPath to find id of <
contains function can do it.
$nodes = $xpath->query("//b[contains(., 'value1')] | //b[contains(., 'value2')]");
And then, to get the parent id
$parent_id = $nodes->item(0)->parentNode->getAttribute("id");
A demo (with HTML) here.