I've just started delving into DOMDocument objects for working with XML files. It's pretty overwhelming!
So far, I haven't seen any examples of how to do what I need to do:
- Read in an XML file.
- Delete all of the nodes that match certain criteria.
- Write the resulting data back into the XML file (or a different file).
My XML structure is something like this:
<?xml etc.......>
<abc>
<def>
<item>
<name>Sample name 1</name>
<date>2006-12-10</date>
</item>
<item>
<name>Sample name 2</name>
<date>2006-12-12</date>
</item>
</def>
</abc>
I want write a function that will delete the item nodes where the date is less than a date that is passed to the function. So if 2006-12-11 is passed in, the resulting file would look like this:
<?xml etc.......>
<abc>
<def>
<item>
<name>Sample name 2</name>
<date>2006-12-12</date>
</item>
</def>
</abc>
I understand the basics, like DOMDocument_load() for loading the file into a DOMDocument object for processing. But I don't see any DOMDocument methods for deleting nodes within the DOMDocument, I only see DOMNode methods for deleting (dumping, removing) children/nodes.
Can someone point me in the right direction?
Many thanks,
Rich