By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,663 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,663 IT Pros & Developers. It's quick & easy.

Query data (SELECT * FROM table) from XML File

P: n/a
Hi all

On SQL Server tables I use SqlDataReader to query data
like "SELECT * FROM table".

Is there something similar for XML Files ?
I want to use SQL Syntax like "SELECT * FROM table" on
a XML file. After query I want to get something like SqlDataReader
based on Query to loop.
I do not want to use a DataSet. It should be more like streaming
and not loading the whole set into Memory.

Any ideas ?
Thanks for any comments.

Best regards
Frank
Jun 27 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On May 15, 11:00 am, Frank Uray <FrankU...@discussions.microsoft.com>
wrote:
On SQL Server tables I use SqlDataReader to query data
like "SELECT * FROM table".

Is there something similar for XML Files ?
I want to use SQL Syntax like "SELECT * FROM table" on
a XML file. After query I want to get something like SqlDataReader
based on Query to loop.
I do not want to use a DataSet. It should be more like streaming
and not loading the whole set into Memory.
If you use LINQ to XML you can use SQL-like syntax (though not SQL
itself) and get compile-time checking too.

I don't know if LINQ to XML supports streaming. This post:
http://blogs.msdn.com/xmlteam/archiv...ml-part-1.aspx
suggests that it doesn't, for input. You may be able to search for
some workarounds though.

Of course, using LINQ to XML to start with assumes you're able to
use .NET 3.5 - is that likely to be a problem for you?

Jon

Jun 27 '08 #2

P: n/a
On May 15, 11:11 am, "Jon Skeet [C# MVP] <sk...@pobox.com>"
<sk...@pobox.comwrote:

<snip>
I don't know if LINQ to XML supports streaming. This post: [...]
suggests that it doesn't, for input. You may be able to search for
some workarounds though.
One example:

http://mtaulty.com/CommunityServer/b...9/08/9803.aspx

Jon
Jun 27 '08 #3

P: n/a
You could use LINQ or XPath & XmlReader but I don’t think there is any SQL
over XML provider
--
Misbah Arefin
http://dotnethitman.spaces.live.com
http://www.linkedin.com/in/misbaharefin


"Frank Uray" <Fr*******@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
Hi all

On SQL Server tables I use SqlDataReader to query data
like "SELECT * FROM table".

Is there something similar for XML Files ?
I want to use SQL Syntax like "SELECT * FROM table" on
a XML file. After query I want to get something like SqlDataReader
based on Query to loop.
I do not want to use a DataSet. It should be more like streaming
and not loading the whole set into Memory.

Any ideas ?
Thanks for any comments.

Best regards
Frank
Jun 27 '08 #4

P: n/a
Frank,

In C# there is not a Linq to XML solution, however what is wrong with the
dataset.

You get mostly an XML file in a dataset with

ds.readXML(path).

The dataset is a very optimized OO collection so I am very interested what
will be the problem?

Every other method will probably consume more memory and at least more
resources.

Cor

"Frank Uray" <Fr*******@discussions.microsoft.comschreef in bericht
news:E3**********************************@microsof t.com...
Hi all

On SQL Server tables I use SqlDataReader to query data
like "SELECT * FROM table".

Is there something similar for XML Files ?
I want to use SQL Syntax like "SELECT * FROM table" on
a XML file. After query I want to get something like SqlDataReader
based on Query to loop.
I do not want to use a DataSet. It should be more like streaming
and not loading the whole set into Memory.

Any ideas ?
Thanks for any comments.

Best regards
Frank

Jun 27 '08 #5

P: n/a
You get mostly an XML file in a dataset with
>
ds.readXML(path).

The dataset is a very optimized OO collection so I am very interested what
will be the problem?
Well, it doesn't work so well with huge volumes...
Every other method will probably consume more memory and at least more
resources.
Well, except XmlReader... I do have a streaming (yield iterator)
XmlReader in my toolkit, but it is quite lengthy and has some
limitations - for example it assumes that all the "fields" are direct
descendents (either elements or attributes) of the element you are
reading, and it takes no account of hierarchy (it just uses
MoveToFollowing to get the next candidate record). Maybe I'll write it
up some time and put it somewhere more public...

Marc
Jun 27 '08 #6

P: n/a
Hi Cor

Thanks for your answer.

I have a application that has online connection
to SQL Server (SqlDataReader ...).
In this application, as a SQL Engineer, I use SQL Syntax.

First is I want SQL Server to select subsets of data,
I dont want to load it all into local Application Memory.
But the real problem is, I want to change application to
be able to run in a offline modus using XML files.

If I would be able to somehow create SqlDataReader from
DataSet and/or XML File, I dont have to change a lot within
the application. Data Syncronizing would not be a big deal.

So, I guess there is no solution to do this and I
have to change the whole application to use DataSet.
Than I am able to use both, online and offline.

Thanks anyway
Frank
"Cor Ligthert [MVP]" wrote:
Frank,

In C# there is not a Linq to XML solution, however what is wrong with the
dataset.

You get mostly an XML file in a dataset with

ds.readXML(path).

The dataset is a very optimized OO collection so I am very interested what
will be the problem?

Every other method will probably consume more memory and at least more
resources.

Cor

"Frank Uray" <Fr*******@discussions.microsoft.comschreef in bericht
news:E3**********************************@microsof t.com...
Hi all

On SQL Server tables I use SqlDataReader to query data
like "SELECT * FROM table".

Is there something similar for XML Files ?
I want to use SQL Syntax like "SELECT * FROM table" on
a XML file. After query I want to get something like SqlDataReader
based on Query to loop.
I do not want to use a DataSet. It should be more like streaming
and not loading the whole set into Memory.

Any ideas ?
Thanks for any comments.

Best regards
Frank


Jun 27 '08 #7

P: n/a
For reference, you might be interested in sync framework:
http://msdn.microsoft.com/en-us/sync/default.aspx
(when it is released, at least...)

Marc
Jun 27 '08 #8

P: n/a
Marc,
Well, it doesn't work so well with huge volumes...
What are in your idea huge volumes, that is very subjective you know?

Cor
Jun 27 '08 #9

P: n/a
What are in your idea huge volumes, that is very subjective you know?

Oh absolutely! That is exacatly why I used a vague term like "huge".
Especially if we include some behemoths on x64 with tons of memory.
As we both know, it depends on too many factors to even go into - but
either way, a streaming API will scale effortlessly, where-as with an
in-memory answer we need to ask "how big"?

But I also agree that streaming APIs aren't necessarily the easiest
from an OO point of view, unless you are just doing aggregates etc.

Marc
Jun 27 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.