where clausule in xml file

S

Smart Software

hi,
i know how to save table content (example: select * from products) to a xml
file

the code below opens the xml file read all records.
i would like to know how i can filter the records like in a query?
can i do something like:
select * from PRODUCTS.XML where id >100 or something????

DataSet ds = new DataSet();
string myXMLfile = @"products.xml";
System.IO.FileStream fsReadXml = new System.IO.FileStream
(myXMLfile, System.IO.FileMode.Open);
try
{
ds.ReadXml(fsReadXml);
XmlReader xrdr = testCommand.ExecuteXmlReader();
xrdr.Read();
Console.WriteLine(xrdr.ReadOuterXml());
foreach (DataRow row in ds.Tables[0].Rows)
{
MessageBox.Show(row["DESCRIPTION"].ToString());
}
......
 
J

Jon Skeet [C# MVP]

i know how to save table content (example: select * from products) to a xml
file

the code below opens the xml file read all records.
i would like to know how i can filter the records like in a query?
can i do something like:
select * from PRODUCTS.XML where id >100 or something????

If you're using .NET 3.5, the best way of working would be to either
use a typed dataset and LINQ to DataSet, or LINQ to XML directly.
Either way, you can write your queries in C# 3 with a query
expression. If you're not using .NET 3.5 life becomes a bit harder,
unfortunately. You can probably do it without *too* much effort, but I
wouldn't like to say how off the top of my head. (I don't use datasets
much.)

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top