To set a hidden id that can be used by $dom->getElementById() apply setAttribute('id', true) as in the following example
$createItemNode = function ($data) use ($dom) {
$node = $dom->createElement("Item");
$node->setAttribute('id', $data->id);
$node->setAttribute('hed', $data->hed);
$node->setAttribute('run_time', $data->run_time);
$node->setAttribute('date', $data->date);
// Internally mark the id as 'xml:id' for getElementById to work. Adding xml:id manually to the tag will cause loadXML to throw an error DOMDocument: xml:id is not a NCName in Entity
$node->setIdAttribute('id', true);
return $node;
};
With $node->setIdAttribute('id', true), $dom->getElementById($id) will work
When you do $dom->saveXML(), the final doc will not contain any xml:id attribute.