i have a an xml file and would like to extract the elements from xml and popoulate the text boxes in the web form with those data. but couldnt solve it.
i am confused actually..
any idea?
Thanks
//Use an xmlDocument
XmlDocument doc = new XmlDocument();
//Load the XML document. You can also load from a file
doc.LoadXml(@"<root>
<category name='name'>innerCat1
<element att1='dd' att2='Sfw' att3='value' />
</category>
<category name='name2'>innerCat2
<element att1='value' att2='value' att3='value' />
</category>
</root>");
//Use XPath to select nodes
XmlNode node = doc.SelectSingleNode(@"root/category");
//Assign values to textboxes
//Value form element
TextBox1.Text = node.SelectSingleNode("element").Attributes["att1"].Value;
//Value from node inner text
TextBox2.Text = node.InnerText;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.