Click here to Skip to main content
15,895,192 members
Home / Discussions / C#
   

C#

 
QuestionIncluding a "using System.X" object Pin
Manfr3d15-Jul-07 2:44
Manfr3d15-Jul-07 2:44 
AnswerRe: Including a "using System.X" object Pin
mav.northwind15-Jul-07 3:08
mav.northwind15-Jul-07 3:08 
QuestionEmail Pin
mcaos15-Jul-07 2:10
professionalmcaos15-Jul-07 2:10 
AnswerRe: Email Pin
martin_hughes15-Jul-07 3:12
martin_hughes15-Jul-07 3:12 
AnswerRe: Email Pin
mav.northwind15-Jul-07 3:15
mav.northwind15-Jul-07 3:15 
QuestionAppend new node to XML file Pin
saud_a_k15-Jul-07 1:34
saud_a_k15-Jul-07 1:34 
AnswerRe: Append new node to XML file Pin
mav.northwind15-Jul-07 2:18
mav.northwind15-Jul-07 2:18 
GeneralRe: Append new node to XML file Pin
saud_a_k15-Jul-07 19:25
saud_a_k15-Jul-07 19:25 
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...

Questionhow to pass variable between classes in window application Pin
mhp13015-Jul-07 0:00
mhp13015-Jul-07 0:00 
AnswerRe: how to pass variable between classes in window application Pin
Guffa15-Jul-07 0:11
Guffa15-Jul-07 0:11 
GeneralRe: how to pass variable between classes in window application Pin
mhp13015-Jul-07 0:13
mhp13015-Jul-07 0:13 
AnswerRe: how to pass variable between classes in window application Pin
Muhammad Gouda15-Jul-07 0:17
Muhammad Gouda15-Jul-07 0:17 
GeneralRe: how to pass variable between classes in window application Pin
Colin Angus Mackay15-Jul-07 1:15
Colin Angus Mackay15-Jul-07 1:15 
GeneralRe: how to pass variable between classes in window application Pin
Muhammad Gouda15-Jul-07 1:30
Muhammad Gouda15-Jul-07 1:30 
GeneralRe: how to pass variable between classes in window application Pin
Luc Pattyn15-Jul-07 1:47
sitebuilderLuc Pattyn15-Jul-07 1:47 
GeneralRe: how to pass variable between classes in window application Pin
Colin Angus Mackay15-Jul-07 2:05
Colin Angus Mackay15-Jul-07 2:05 
GeneralRe: how to pass variable between classes in window application Pin
Colin Angus Mackay15-Jul-07 1:08
Colin Angus Mackay15-Jul-07 1:08 
QuestionWindows Form in web form Pin
ankit_mait14-Jul-07 23:03
ankit_mait14-Jul-07 23:03 
AnswerRe: Windows Form in web form Pin
Manas Bhardwaj14-Jul-07 23:28
professionalManas Bhardwaj14-Jul-07 23:28 
GeneralRe: Windows Form in web form Pin
Christian Graus15-Jul-07 6:19
protectorChristian Graus15-Jul-07 6:19 
GeneralRe: Windows Form in web form Pin
ankit_mait16-Jul-07 6:26
ankit_mait16-Jul-07 6:26 
AnswerRe: Windows Form in web form Pin
WillemM14-Jul-07 23:40
WillemM14-Jul-07 23:40 
Questionbutton appearance Pin
Maddie from Dartford14-Jul-07 22:02
Maddie from Dartford14-Jul-07 22:02 
AnswerRe: button appearance Pin
mav.northwind14-Jul-07 22:18
mav.northwind14-Jul-07 22:18 
GeneralRe: button appearance Pin
Maddie from Dartford14-Jul-07 22:28
Maddie from Dartford14-Jul-07 22:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.