•
•
•
•
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
![]() |
•
•
Join Date: Feb 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb XML, XSLT and XPATH Marketplace
- append to XML file (Visual Basic 4 / 5 / 6)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: different minOccurs for different operations?
- Next Thread: XML Linking !!!


Linear Mode