Xml File Read and Bind

Description :


This code shows how to read xml file and bind value.

XML File like this

< NewDataSet >
< Table >
< Country > British Indian Ocean Territory< /Country >
< City > Diego Garcia< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Ahmadabad< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Akola< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Aurangabad Chikalthan Aerodrome< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bombay / Santacruz< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bilaspur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bhuj-Rudramata< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Belgaum / Sambra< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bhopal / Bairagarh< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bhaunagar< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Goa / Dabolim Airport< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Indore< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Jabalpur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Khandwa< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Kolhapur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Nagpur Sonegaon< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Rajkot< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Sholapur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Agartala< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Siliguri< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bhubaneswar< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Calcutta / Dum Dum< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Car Nicobar< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Gorakhpur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Gauhati< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Gaya< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Imphal Tulihal< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Jharsuguda< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Jamshedpur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > North Lakhimpur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Dibrugarh / Mohanbari< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Port Blair< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Patna< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > M. O. Ranchi< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Agra< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Allahabad / Bamhrauli< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Amritsar< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Varanasi / Babatpur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bareilly< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Kanpur / Chakeri< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > New Delhi / Safdarjung< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > New Delhi / Palam< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Gwalior< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Hissar< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Jhansi< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Jodhpur< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Jaipur / Sanganer< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Kota Aerodrome< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Lucknow / Amausi< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Satna< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Udaipur Dabok< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Bellary< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Vijayawada / Gannavaram< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Coimbatore / Peelamedu< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Cochin / Willingdon< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Cuddapah< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Hyderabad Airport< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Madurai< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Mangalore / Bajpe< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Madras / Minambakkam< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Tiruchchirapalli< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Thiruvananthapuram< /City >
< /Table >
< Table >
< Country > India< /Country >
< City > Vellore< /City >
< /Table >
< /NewDataSet >


client Side Code


< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server" >
< title >Untitled Page< /title >
< /head >
< body >
< form id="form1" runat="server" >
< div >
< asp:DataGrid ID="dtg1" runat ="Server" AutoGenerateColumns ="false" >
< Columns >
< asp:TemplateColumn HeaderText ="Country" >
< ItemTemplate >
< asp:Label ID="lbl1" runat ="server" Text ='< %# Bind("Country") % >' >< /asp:Label >
< /ItemTemplate >
< /asp:TemplateColumn >


< asp:TemplateColumn HeaderText ="City" >
< ItemTemplate >
< asp:Label ID="lbl2" runat ="server" Text ='< %# Bind("City") % >' >< /asp:Label >
< /ItemTemplate >
< /asp:TemplateColumn >
< /Columns >
< /asp:DataGrid >

< /div >
< /form >
< /body >
< /html >


Server Side

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cls1 = New ClsConnect
ds.ReadXml(Server.MapPath("XMLFile.xml"))
dtg1.DataSource = ds
dtg1.DataBind()
End Sub


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: