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

  • SEARCH
  • Home
  • 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 8289051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:25:09+00:00 2026-06-08T12:25:09+00:00

Okay, it appeared that I had an answer for this question, but I was

  • 0

Okay, it appeared that I had an answer for this question, but I was wrong. Probably because I asked the wrong thing. Here is what I want to do:
I want to take an xml document and pull it into memory. Then, at will, I want to run queries on that document and get information out of it. I want to do this whenever I need data WITHOUT loading the document into memory again. After all, the point is to stop hitting up the disk when I need the data. The methods I’ve been using only work ONCE, and I need to do this multiple times. Here is the code that I tried:

public static class GrabFile
    {
        public static XDocument configData = XDocument.Load(@"myxml.xml");
        public static XmlReader templateReader = configData.CreateReader();
    }

I thought this would copy the document into memory, and I’d be able to use the templateReader to query the configData any time I wanted to by using this:

while (GrabFile.templateReader.Reader())
{
  //get the data I wanted
}

I thought I could put that while statement, and create others to do specific queries in a method, and call them whenever I needed the info. But it only works ONCE.

As I said, I’m not overly familiar with this, so there’s probably a way to do it that’s easy.

Also, people in the other thread wanted an example of what was in the xml document. That’s irrelevant. The point is I want to put the document into memory, then query it as many times as needed with out accessing it from the disk and creating another reader. And yes, I want to use a reader for this.

Perhaps I need to move the pointer in the file in memory back to the top so it’ll read it again?

Thanks for any help.

  • 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-08T12:25:10+00:00Added an answer on June 8, 2026 at 12:25 pm

    Why do you not want to create another reader?

    Just calling GrabFile.configData.CreateReader() each time you need it is the simplest approach. (That won’t load it from disk again, but it will create a separate XmlReader each time you call it.)

    From the docs for XmlReader:

    Represents a reader that provides fast, non-cached, forward-only access to XML data.

    (Emphasis mine.) I don’t see anything around resetting, and I wouldn’t expect to.

    Given that you’ve got the information in an XDocument to start with, I would personally try to do all the querying with that rather than using the rather-harder-to-work-with XmlReader anyway, but obviously that’s your call. It would help if you’d give some justification though – as you say you’re “not overly familiar with this”, so it’s worth revisiting your assumptions about how you’re tackling whatever the higher-level task is.

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

Sidebar

Related Questions

Okay, this is probably a very basic question; but, I'm just getting back in
Okay, so the answer to my question might not be the problem but here's
Okay, so this is a long long shot but here it goes... When IE
OKay, this is probably pretty noob, but I couldn't find how to solve it.
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay, this is probably an embarrassing question as it's almost certainly an issue of
Okay, next PHPExcel question. I have an HTML form that users fill out and
Okay this question is very simple: I have a facebook page, and a website.
Okay, I feel a bit foolish for having to ask this but I guess
Okay so my question is this. Say I have a simple C++ code: #include

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.