Re: XmlTextReader and Writer
You can not do that (the deletion) with XmlTextWriter. Use the DOM approach for that:
http://www.devsource.com/article2/0,1895,1934067,00.asp
Re: XmlTextReader and Writer
Have you tried
Code:
XmlTextWriter tr = new XmlTextWriter("Items.xml",null);
tr.Formatting = Formatting.Indented;
tr.WriteStartDocument();
tr.WriteStartElement("Items");
tr.WriteStartElement("books");
tr.WriteElementString("book2","lotr");
tr.WriteEndElement();
tr.Flush();
tr.Close();
This should create exactly the code you wanted.
Re: XmlTextReader and Writer
thanks for the website that is exactly what i want. I have one more question
Code:
XmlNodeList nodeList = doc.SelectNodes("//Authors");
in the above code what is the meaning of the slashes?
it is written that "Each slash represents a level in the element hierarchy." But i cannot understand what it means.
Re: XmlTextReader and Writer
That is an XPath expression that selects all the Authors nodes in the document.
http://www.w3schools.com/xpath/xpath_syntax.asp
Quote:
// Selects nodes in the document from the current node that match the selection no matter where they are