Query XML document using ADO.NET?

  • Thread starter Thread starter Dave
  • Start date Start date
You can read your XML document into a dataset and query /
manipulate it from there.... myDataSet.ReadXML
("C:\YourXMLFile.xml")
 
Sure....depending on your XML document, you will have one
or more DataTables in your dataset once you use ReadXML.

So you have a Tables collection at this point.

You can use a DataView for instance which you declare
and reference to a table... DataView dv = new DataView
(myDataSet.Tables[0].DefaultView);

then you use the Rowfilter pretty much like you would a
Select Statement in SQL..

dv.RowFilter = "Last_Name = '" + someVariableOrControl
+ "'";

You can bind a grid or other control to this view and it
will display the filtered information.

You can also sort views and do a lot of other things.

Similarly, once you have your Tables you can use
Find....here's a sample from MSDN...

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfSystemDataDataRowCollectionClassFindTopi
c1.asp
 
Back
Top