Click here to Skip to main content
Licence CPOL
First Posted 17 Jun 2009
Views 6,366
Bookmarked 5 times

How to stream XLINQ

By | 17 Jun 2009 | Technical Blog
From time to time when you are using XLINQ to query XML data, you may find that you are dealing with a very large XML file. Loading a very large XML file using the standard XLINQ Load() method may not be appropraite due to the size of the XML file. Instead some sort of streaming [...]
A Technical Blog article. View original blog here.[^]

From time to time when you are using XLINQ to query XML data, you may find that you are dealing with a very large XML file. Loading a very large XML file using the standard XLINQ Load() method may not be appropraite due to the size of the XML file. Instead some sort of streaming XML approach may be prefferable.

But XLINQ doesnt offer this facility straight out of the box, but with a bit of trickery we can get a XMLReader to do this streaming for us. Lets see an example shall we.

stream12.png

Thats the standard XLINQ query, but we still need to use an XmlReader to do the streaming, so lets see that part, its simply as shown below

stream22.png

And thats it, its a simple as that. We can now query a large XML file using XLINQ and be safe in the knowledge that it will be streamed using an XmlReader and the Yield keyword.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Sacha Barber

Software Developer (Senior)

United Kingdom United Kingdom

Member

I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
 
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
 
Both of these at Sussex University UK.
 
Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 17 Jun 2009
Article Copyright 2009 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid