Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:56:15+00:00 2026-06-01T13:56:15+00:00

Currently one my DAL methods uses the ExecuteXmlReader command to read and append to

  • 0

Currently one my DAL methods uses the ExecuteXmlReader command to read and append to a StringBuilder object and return XML as a string. I realize this isn’t the best way to handle very large files (200MB+) as when the ToString() method is called on StringBuilder it throws an out of memory exception.

There are certain constraints I need to adhere by – I cannot return a XMLReader out of the DAL (db connection stays open, etc), this XML will have to be written to file and keeping it’s formatting for various reasons, currently using an XMLTextWriter’s WriteRaw method for that purpose.

What would be the best data type to return from the DAL to make all this work with large XML files?
I explored the options of using a DataSet, Memory Stream and a Byte Array – but each have their shortfalls. I am looking for the best practice and some code samples would be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:56:16+00:00Added an answer on June 1, 2026 at 1:56 pm

    You can use XDocument the work with your xml files. You can use linq to xml to query through your elements. An example is below:

    XDocument document = XDocument.Load("http://someurl.com/data.xml");
    
    var elements = from element in document.Descendants("SomeElement")
                   select element;
    
    Console.WriteLine(elements.First().Value);
    

    If you also get the out of memory exception with this (i think you will), then you should take a look at the following post:

    http://james.newtonking.com/archive/2007/12/11/linq-to-xml-over-large-documents.aspx

    More information about the XDocument class can be found here:

    http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.aspx

    and here

    http://www.hookedonlinq.com/Print.aspx?Page=LINQtoXML5MinuteOverview

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Earlier I asked this question How to correctly unit test my DAL? , one
Currently one of the reports reads the month_ref which is created like this: ((DATEPART(yy,
I'm currently upgrading one of my websites from the old system to HTML5 and
how can I check if a user (not the one currently logged in) is
Is it possible to render another page instead of one currently being processed? For
I'm working on re-compiling some Pro*C code that no one currently at my company
I am new to Java web-services and am working on one currently, using Apache
I'm using (GNU) Make in my project. I'm currently putting one makefile per directory
I'm currently re-writing one of my old PHP scripts so that the code is
I'm currently trying to get one of my unit tests to work, but there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.