User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the XML, XSLT and XPATH section within the Software Development category of DaniWeb, a massive community of 373,936 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,475 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our XML, XSLT and XPATH advertiser:
Views: 939 | Replies: 0
Reply
Join Date: Feb 2008
Posts: 2
Reputation: Daljeet Hanspal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Daljeet Hanspal Daljeet Hanspal is offline Offline
Newbie Poster

appending a new node to am existing xml file

  #1  
Mar 27th, 2008
hi ....
i am trying to add a new node to an existing xml file in c# ..........
the code is as follows:

XmlDocument doc = new XmlDocument();
string filename = @"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\xml\xml\bin\Debug\bookstore.xml";
//create a new node
XmlElement newbook = doc.CreateElement("book");

//set attribute
newbook.SetAttribute(label1.Text, textBox1.Text);

//create new element
XmlElement npublication = doc.CreateElement(label2.Text);
npublication.InnerText = textBox2.Text;
newbook.AppendChild(npublication);

XmlNode xn = doc.DocumentElement;
xn.AppendChild(newbook);


i get this message "Object reference not set to an instance of an object."

please help me out
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb XML, XSLT and XPATH Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the XML, XSLT and XPATH Forum

All times are GMT -4. The time now is 6:43 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC