i want to select data from xml file where id=1;
then outcome output bind with Detalview..
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lalit MRank #1,186 · 1.5K reputationPosted Jan 3, 2010, 7:41 PM EST
do first create a new XML-File and populate it with some data,show here example:
?xml version="1.0" encoding="utf-8" ?> Employee> em> id>1/id> name>Florian/name> phone>123/phone> /em> em> id>2/id> name>Andreas/name> phone>234/phone> /em> em> id>3/id> name>Martin/name> phone>345/phone> /em> /Employee>Drag a GridView control on your web form. Next you need some code to bind the data from the XML-file to your GridView.
Imports System.Data Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim oDs As New DataSet oDs.ReadXml(Request.PhysicalApplicationPath + "XMLFile.xml") GridView1.DataSource = oDs GridView1.DataBind() End Sub End ClassPage_Loadevent we create a new DataSet and use the methodReadXmlto get the data from the XML-file. Then we bind the DataSet to the GridViewSanthosh NRank #4,788 · 325 reputationPosted Jan 3, 2010, 8:04 PM EST
xml.LoadXml(str); // suppose that str string contains "
//alternatively you can use Load to load xml file by giving path of the file..
//Use xpath to select nodes based on the attribute value as
XmlNodeList xnList = xml.SelectNodes("/Root/Inbox[@id='1']");
this is how you generate filtered nodes...
If you wanted to show selected nodes in gridview then you can easily do that directly by using xmldatasource property and setting xpath expression...
check here for exanmple and explaination on how to do this..
http://msdn.microsoft.com/en-us/library/aa479341.aspx