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


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Reading Xml Files Through asp.net

Posted By:Gowthammanju       Posted Date: June 14, 2011    Points: 25    Category:    URL: http://www.dotnetspark.com  

This articles provides a way of approach for accessing the xml files through asp.net
 


First we create sample xml files in asp.net as:


SS.Gowthaman Sample XML Document Sample generation file for accessing data through xml


Reading the contents of xml file in asp.net as:


use namespace as

System.Xml

coding as

XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/App_Data/sample.xml"));

In the design page paste the content inside the form as

Name
Title
Body
In page load event write the coding as

       XmlDocument doc = new XmlDocument();
	doc.Load(Server.MapPath("~/App_Data/sample.xml"));

	XmlNode root = doc.DocumentElement;
	AuthorLiteral.Text = root.SelectSingleNode("author").ChildNodes[0].Value;
	TitleLiteral.Text = root.SelectSingleNode("title").ChildNodes[0].Value;
	BodyLiteral.Text = root.SelectSingleNode("body").ChildNodes[0].Value;

that's it.......


this way u will find the solution



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

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