I have a dom element of which i want to find if exists a specific sub-element.
My node is like this:
<properties>
<property name="a-random-neme" option="option2" >value1</property>
<property name="another-random-name">V2</property>
<property name="yet-another-random-name" option="option5" >K3</property>
</properties>
in php it is referenced by a dom object
$properties_node;
In another part of php code I want to check if a datum I'm going to add already exists
$datum = [ 'name'=>'yet-another-random-name', 'value'=>'K3'];
//NOTE: If other attributes exists I want to keep them
$prop=$dom->createElement('property',$datum['value']);
$prop->setAttribute('name', $datum['name']);
if(prop_list_contains($properties-node,$prop,['name']))
$properties_node->appendChild($prop);
else
echo "not adding element, found\n";
now I want to make
/**
@param $properties_node reference to the existing dom object
@param $prop the new element I want to add
@param $required_matches an array containing the name of the attributes that must match
@return matching element if match is found, false otherweise
*/
function prop_list_contains(&$properties_node,$prop,array $required_matches){
// here I have no Idea how to parse the document I have
return false
}
Desiderata:
not adding element, found