.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Dynamic creation of xml Elements in C#.net

Posted By: Narayanan     Posted Date: May 24, 2011    Points:5   Category :C#
Hi friends,
I created a Dynamic textbox and insert a value into XML.I send my code for u reference.
My code for XML Creation.
string sFilename = xmlpath;
XmlDocument xmlDoc = new XmlDocument();
String XmlSpecification = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
XmlSpecification = XmlSpecification + Environment.NewLine + "<Testing></Testing>";
File.AppendAllText(xmlpath, XmlSpecification);
XmlElement elmXML = xmlDoc.CreateElement("Configuration");
string strConfiguration = String.Empty;
for (int index = 0; index < 3; index++)

string targetTextBox = "Textbox" + index;
//Try to find the textbox
int textBoxIndex = gb.Controls.IndexOfKey(targetTextBox);
if (textBoxIndex != -1)
TextBox foundTextBox = (TextBox)gb.Controls[textBoxIndex];
Userprefrenece.txt1 = foundTextBox.Text;
String str = "port" + index.ToString();
strConfiguration = strConfiguration + Environment.NewLine + @"<str>" + Userprefrenece.txt1 + "</str>";


elmXML.InnerXml = strConfiguration;
MessageBox.Show("Saved Successfully");
I saved successfully. How can retrieve from XML. But I didn't get correct.
My XML Data

<?xml version="1.0" encoding="utf-8" ?>
- <Testing>
- <Configuration>
retrieve is my problem.How can i retrieve data from xml.and store in the textbox .Please help me Urgent
Lakshmi Narayanan.S

Author: Dhiraj Ranka             
Posted Date: May 25, 2011     Points: 20   


You can follow this link to read your XML file


Hope this helps

Hope this helps.

Thanks & Regards,
Dhiraj Ranka
http://www.twitter.com/dhirajranka | http://www.dhirajranka.com

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend