PDA

View Full Version : PHP, Deleting XML Values



randomnoob
September 18th, 2009, 03:48
I Have an XML Document. I have worked out how to add an assignment, but I don't know how to delete one.

<assignmentlookup>
<assignment>
<name>maths</name>
<due>duedate</due>
<marks>outof20</marks>
</assignment>
<assignment>
<name>english</name>
<due>duedate</due>
<marks>outof10</marks>
</assignment>
</assignmentlookup>

How would I go about deleting this whole block from the document.

<assignment>
<name>english</name>
<due>duedate</due>
<marks>outof10</marks>
</assignment>

I would prefer the answer was using the DOM library.

Dynash
September 18th, 2009, 09:47
http://www.xml-training-guide.com/append-delete-data-from-xml-using-php.html

iBrightDev
September 18th, 2009, 12:01
Dynash, that is a useful link that i didnt even know about. thanks man. :)

+1 for you. ooo, got you a second light green now. :D

randomnoob
September 19th, 2009, 01:47
Are you mocking me or something :S?

The only deleting that site shows is the removal of text nodes.

From the site:


you can use the deleteData function to delete some characters after you have created a text node.

I am interested in removing elements.

Dynash
September 19th, 2009, 07:54
http://www.phpbuilder.com/board/showpost.php?p=10681558&postcount=5