Hi bhuwan,
For Example,Here Lets take an XML file as your Datasource.
ASPX Page:-
<asp:TextBox ID="ttt" runat="server"></asp:TextBox>
Then create an xml file as follows:-
XML file
<Address>
<Pin>500070</Pin>
</Address>
Then In code Behind(.cs),Use
System.xml
namespace Write below code:-
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/XMLFile.xml"));
XmlNode root = doc.DocumentElement;
ttt.Text = root.SelectSingleNode("Pin").ChildNodes[0].Value.ToString();
In above code,We are creating an object for 'xmlDocument' which is present in system.xml.This 'XmlDocument' is used to load all the xml data.In the next step We are loading the xml data from an xml file(Here XMLFile.xml).
In the Next step.'DocumentElement' gets the Root element for the Document and assigning the root value to 'XmlNode' object(Here 'XmlNode' Represents root Node).In nextstep we are using 'xmlnode' object to select a single Node and its ChildNode value.At last We are assigning this value to Textbox.(Here root contains <Address> node and selecting <pin> node and printing the text Present in <pin> node in the TextBox).
Thanqs & Regards
Dharanidhar
Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator