TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lakshmi Narayanan
NA
10
14.9k
Dynamic creation of XML Elements in C#.net
May 25 2011 12:51 AM
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);
xmlDoc.Load(sFilename);
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;
xmlDoc.DocumentElement.AppendChild(elmXML);
xmlDoc.Save(sFilename);
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>
<str>NARAAYANAN</str>
<str>DELL</str>
<str>SUCCESS</str>
</Configuration>
</Testing>
retrieve is my problem.How can i retrieve data from xml.and store in the textbox .Please help me Urgent
Regards,
Lakshmi Narayanan.S
Reply
Answers (
1
)
Need Help in RFID Programming :) about writing XML in windows ce device ATID or windows ce operation file
Xml not read properly