Have been struggling with this for a while. For some reason nothing works for me.
I have a xml file like this:
<messages>
<message>
<name>John</name>
<content>Hello</content>
</message>
<message>
<name>dd</name>
<content>Whats up</content>
</message>
</messages>
Now I am trying to write a JavaScript button, that removes a certain element "message". What I have tried to differentiate between "message" elements:
- Have each element "message" include an element "id". That didn't help because I don't know if it's possible to identify a certain element by only knowing one of its subelements.
- Have each element "message" own an attribute. And then delete the element that owns a certain attribute id="1" for example.
I think the latter idea is better, but I can't figure out how to delete an element by attribute.
Am I missing something completely obvious here that would make everything easier?
Thanks
EDIT: I now know what happened. It deleted the element from the variable, but I want it to delete it from messages.xml. Modified data wasn't being sent back to the file itself. How would I go about doing that?