I'm sorry I posted only the function of creating one node... I grabbed code from www.kirupa.com , all of it is here..
private XmlDocument xmlDoc = new XmlDocument();
private XmlElement booksElement;
private void AddBook(string ISBN, string title, string author)
{
//
// Initialize booksElement if you are adding your first book.
//
if (booksElement == null)
{
booksElement = xmlDoc.CreateElement("Books");
}
XmlElement bookElement = xmlDoc.CreateElement("Book");
XmlAttribute bookAttribute = xmlDoc.CreateAttribute("ISBN");
bookElement.SetAttributeNode(bookAttribute);
bookAttribute.Value = ISBN;
XmlElement titleElement = xmlDoc.CreateElement("title");
titleElement.InnerText = title;
bookElement.AppendChild(titleElement);
XmlElement authorElement = xmlDoc.CreateElement("author");
authorElement.InnerText = author;
bookElement.AppendChild(authorElement);
booksElement.AppendChild(bookElement);
}
private void WriteToDisk(string path)
{
// Add the booksElement to our root element and write to disk
xmlDoc.AppendChild(booksElement);
xmlDoc.Save(path);
}
static void Main(string[] args)
{
Program bookList = new Program();
bookList.AddBook("0553212419", "Sherlock Holmes: Complete Novels and Stories, Vol 1", "Sir Arthur Conan Doyle");
bookList.AddBook("0743273567", "The Great Gatsby", "F. Scott Fitzgerald");
bookList.AddBook("0684826976", "Undaunted Courage", "Stephen E. Ambrose");
bookList.AddBook("0743203178", "Nothing Like It In the World", "Stephen E. Ambrose");
bookList.WriteToDisk(@"C:\books.xml");
}
So you see this creates a file OK.... But If I cannot ue this function to Append to the saved books.xml file. meanwhile, I try the SelectSingleNode, and see if it works.
_____________________________________________________ Yea! I could be wrong...