I've have figured out how to read from an xml file and I can retrieve the data I need.
My problem seems to be that I can not figure out how to insert some data that someone has entered or remove certain data.
There seems to be a lot of info here if you want to read data from an xml file, but I could not find much on writing or removing data from an xml file. I've been to the unofficial wiki (great tutorial on how to retrieve xml from web), but nothing that I could find on editing a xml file. I have tried various web sites as well as the widget manual (but I cant seem to get all the pieces to work), and after a week I have decided to take it to this forum.
here is an example of my xml file called (xmlFile.xml). This is accessed from my hard drive.
CODE
<?xml version="1.0" encoding="utf-8"?>
<ipData>
<ipSelection selection="testSelection1">
<connectionName>TestConnection1</connectionName>
<ip>111-111-888-888</ip>
<mask>111-222-888-888</mask>
<gate>111-333-888-888</gate>
<dns1>111-444-888-888</dns1>
<dns2>111-555-888-888</dns2>
<win1>111-666-888-888</win1>
<win2>111-777-888-888</win2>
</ipSelection>
<ipSelection selection="testSelection2">
<connectionName>TestConnection2</connectionName>
<ip>222-111-888-888</ip>
<mask>222-222-888-888</mask>
<gate>222-333-888-888</gate>
<dns1>222-444-888-888</dns1>
<dns2>222-555-888-888</dns2>
<win1>222-666-888-888</win1>
<win2>222-777-888-888</win2>
</ipSelection>
<ipSelection selection="testSelection3">
<connectionName>TestConnection3</connectionName>
<ip>333-111-888-888</ip>
<mask>333-222-888-888</mask>
<gate>333-333-888-888</gate>
<dns1>333-444-888-888</dns1>
<dns2>333-555-888-888</dns2>
<win1>333-666-888-888</win1>
<win2>333-777-888-888</win2>
</ipSelection>
</ipData>
I travel to different locations with my labtop and just wanted to make a widget that would allow me to select a certain location and have it change the ip settings on my computer (right now I use batch files, which are not a problem and pretty easy to click on and run), but I figured what the heck, I'll make a widget so I can get some more experience programming as well as learning XML.
I want to be able to enter a new locations name and ip address and have it add that data to the xml file. example below.
CODE
<ipSelection selection="testSelection4">
<connectionName>TestConnection4</connectionName>
<ip>444-111-888-888</ip>
<mask>444-222-888-888</mask>
<gate>444-333-888-888</gate>
<dns1>444-444-888-888</dns1>
<dns2>444-555-888-888</dns2>
<win1>444-666-888-888</win1>
<win2>444-777-888-888</win2>
</ipSelection>
I would also like to be able to delete/remove a <ipSelection> </ipSelection> element/node if I no longer need that location listed.
Thanks for any help you can give.
Allister Fiend
edit correction - added sentence that mentions xml file is located on hard drive.