Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi guys,

I want to write a textbox text in xml node in asp.net from *.cs file in existing xml file.

Thanks in advance
Posted
Updated 31-Aug-11 22:22pm
v2
Comments
Prerak Patel 1-Sep-11 4:23am    
Did you google?

C#
string filename = @"c:\test\XMLFile.xml";
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlNode node = doc.CreateNode(XmlNodeType.Element, "New Node name", null);
node.InnerText = "this is text from your textbox";
doc.DocumentElement.AppendChild(node);
doc.Save(filename);
 
Share this answer
 
v2
Comments
adadsadsasd 1-Sep-11 5:35am    
sorry, but when i am doing this. first time it running simply. but when i click on other image it erase previous data and write a new image name. i want when i am click on image its name is save in image but my previous data not delete. but this is also helpful for me. but please help me to complete my project just i ask question. thnx..
Hasan.Hof 1-Sep-11 6:41am    
we are using the AppendChild() function to append a new element.so it should not replace your previous data rather it will append it to the existing data.
adadsadsasd 1-Sep-11 7:25am    
can i know the complete code. i dont know anything about XMl code. please help me..!!!
Hasan.Hof 1-Sep-11 8:02am    
http://omegacoder.com/?p=46
Check this it may help you.

First go through the xml stuffs in www.w3schools.com.
Then it will become easy.

Cheers.
There are number of Tutorials available in CodeProject on the same. Here is some of them
Manipulate XML data with XPath and XmlDocument (C#)[^]
Using XML in C# in the simplest way[^]
C# Application with XML File[^]
Go through the tutorials. You will able to understand the stuff better and then do the stuff yourself.
Cheers !
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900