I have an xml file like this:
<uploads>
<upload>
<name>asd</name>
<type>123</name>
</upload>
<upload>
<name>qwe</name>
<type>456</name>
</upload>
</uploads>
Now I want to delete a node upload that has a name child as (say qwe). How can I delete it using php , so that the resulting xml is
<uploads>
<upload>
<name>asd</name>
<type>123</name>
</upload>
</uploads>
I do not have too much knowledge about xml and related techniques. Is it possible to do it using xpath, like this $xml->xpath('//upload//name')
? Assuming $xml
was loaded using simplexml_load_file()
function.
For reference, I was using this question to do what I want. But, it selects the element based on an attribute and I want to select an element based on the value of it child node.