hkullana
August 26th, 2007, 02:49 PM
hi,
i have the code
XmlTextWriter tr = new XmlTextWriter("Items.xml",null);
tr.Formatting = Formatting.Indented;
tr.WriteStartDocument();
tr.WriteStartElement("Items");
tr.WriteStartElement("books");
tr.WriteElementString("book1","harry");
tr.WriteElementString("book2","lotr");
tr.WriteEndElement();
tr.Flush();
tr.Close();
so it generates the xml code below
<?xml version="1.0" ?>
- <Items>
- <books>
<book1>harry</book1>
<book2>lotr</book2>
</books>
</Items>
Now i want to delete the tag <book1> and its text harry from the file. How can i do it? (after the deletion the xml file will look like this: )
<?xml version="1.0" ?>
- <Items>
- <books>
<book2>lotr</book2>
</books>
</Items>
i have the code
XmlTextWriter tr = new XmlTextWriter("Items.xml",null);
tr.Formatting = Formatting.Indented;
tr.WriteStartDocument();
tr.WriteStartElement("Items");
tr.WriteStartElement("books");
tr.WriteElementString("book1","harry");
tr.WriteElementString("book2","lotr");
tr.WriteEndElement();
tr.Flush();
tr.Close();
so it generates the xml code below
<?xml version="1.0" ?>
- <Items>
- <books>
<book1>harry</book1>
<book2>lotr</book2>
</books>
</Items>
Now i want to delete the tag <book1> and its text harry from the file. How can i do it? (after the deletion the xml file will look like this: )
<?xml version="1.0" ?>
- <Items>
- <books>
<book2>lotr</book2>
</books>
</Items>