I have a following XML file(auto.xml)
// the value entered in textboxes should be written here
in aspx page I have 2 textboxes and a button. Suppose I enter 'Checking fault on' in first textbox and 'Already checked' in second textbox and click on the add button, then the first value should be added as the third node value and the second textbox value should be added as the attribute value.
i.e., the xml file should look like this
And also how to delete that node from XML ? i.e., if I click on delete button then that node should be removed from the XML file.
Thanks,
Sachi
VulpesPosted Dec 6, 2011, 7:04 AM
sachi vasishtaPosted Dec 6, 2011, 12:22 AM
Yes, 'selectedvalue' is a single word.
coming to the second part , my UI will display the node and its attribute value like below.(node and its attribute value will be shown in textboxes)
node1value node1attributevalue editbutton deletebutton
node2value node2attributevalue editbutton deletebutton
node3value node3attributevalue editbutton deletebutton
example:
Pending fault found on Pending fault editbutton delbutton
now if I click on delete button then that node(in my sample xml file, the first node under fault element) info should be removed from the UI as well as from the XML file, and if I edit one of the textboxes or both and click on edit button ,then the edited value should appear in UI as well as in XML file of that particular node.
Sam HobbsPosted Dec 5, 2011, 2:45 PM
Note that there are many ways to read and write XML.
VulpesPosted Dec 5, 2011, 5:12 AM
XElement auto = XElement.Load("auto.xml");
XElement fault = auto.Element("fault");
XElement text = new XElement("text", new XAttribute("selectedvalue", TextBox2.Text), Text.Box1.Text);
fault.Add(text);
auto.Save("auto.xml"); // if you want to save immediately to disk
Regarding the second part, how do you know which node should be removed? Will it always be the last one added?