|
-
Jul 9th, 2007, 11:53 AM
#1
Thread Starter
Hyperactive Member
[2.0] Deleting a node from XML
Hi all:
I'm trying to do some manipulation with an xml file. What I'm doing is trying to store and manipulate a small amount of data, but not with a database but an XML file. So the following xml file simply saves settings each with a name, head and tail value. For each new setting, there is another setting node inserted.
Code:
<?xml version="1.0"?>
<PDFBUILDER>
<RENAMESETTINGS>
<SETTING>
<NAME Type="Name">TEST</NAME>
<HEAD Type="Head">df</HEAD>
<TAIL Type="Tail">def</TAIL>
</SETTING>
<SETTING>
<NAME Type="Name">2TEST</NAME>
<HEAD Type="Head">esser</HEAD>
<TAIL Type="Tail">deesr</TAIL>
</SETTING>
<SETTING>
<NAME Type="Name">bbdos</NAME>
<HEAD Type="Head">ewr</HEAD>
<TAIL Type="Tail" />
</SETTING>
</RENAMESETTINGS>
</PDFBUILDER>
The problem comes in when I want to user to delete a node / setting. Say for e.g., if the user wanted to delete the setting named: 2TEST, is there anyway to read in the xml from the file, and delete the node:
<SETTING>
<NAME Type="Name">2TEST</NAME>
<HEAD Type="Head">esser</HEAD>
<TAIL Type="Tail">deesr</TAIL>
</SETTING>
And then write back the result to the file? Thus what I want to write back to the file will be:
<?xml version="1.0"?>
<PDFBUILDER>
<RENAMESETTINGS>
<SETTING>
<NAME Type="Name">TEST</NAME>
<HEAD Type="Head">df</HEAD>
<TAIL Type="Tail">def</TAIL>
</SETTING>
<SETTING>
<NAME Type="Name">bbdos</NAME>
<HEAD Type="Head">ewr</HEAD>
<TAIL Type="Tail" />
</SETTING>
</RENAMESETTINGS>
</PDFBUILDER>
Now I know how to write to xml files etc. what I don't know is how to extract and delete a node for e.g. 2TEST.
Could anyone help me with this?
Jennifer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|