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 4006538
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:31:37+00:00 2026-05-20T08:31:37+00:00

Suppose i have an XML file, that i use as local database, like this):

  • 0

Suppose i have an XML file, that i use as local database, like this):

<root>
 <address>
  <firstName></firstName>
  <lastName></lastName>
  <phone></phone>
 </address>
</root>

I have a couple of questions:
1. What will be a fastest way to find address(or addresses) in XML where firstName contains ‘er’ for example?
2. Is it possible to do without whole loading of XML file in memory?

P.S. I am not looking for XML file alternatives, ideally i need a search that not depend on count of addresses in XML file. But i am realist, and it seems to me that it not possible.

Update:
I am using .net 4
Thanks for suggestions, but it’s more scientific task than practical.. I probably looking for more fastest ways than linq and xmltextreader.

  • 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-05-20T08:31:37+00:00Added an answer on May 20, 2026 at 8:31 am

    LINQ to Xml works pretty fine:

    XDocument doc = XDocument.Load("myfile.xml");
    var addresses = from address in doc.Root.Elements("address")
                    where address.Element("firstName").Value.Contains("er")
                    select address;
    

    UPDATE: Try to look at this question on StackOverflow: Best way to search data in xml files?.

    Marc Gravell’s accepted answer works using SQL indexing:

    First: how big are the xml files? XmlDocument doesn’t scale to “huge”… but can handle “large” OK.

    Second: can you perhaps put the data
    into a regular database structure
    (perhaps SQL Server Express Edition),
    index it, and access via regular TSQL?
    That will usually out-perform an xpath
    search. Equally, if it is structured,
    SQL Server 2005 and above supports the
    xml data-type, which shreds data –
    this allows you to index and query xml
    data in the database without having
    the entire DOM in memory (it
    translates xpath into relational
    queries).

    UPDATE 2: Read also another link taken by the previous question that explains how the structure of the XML affects performances: http://www.15seconds.com/issue/010410.htm

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

Sidebar

Related Questions

I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose I have an asmx web service at the following address: http://localhost/BudgetWeb/Service.asmx This web
Having been googling for hours, I realize that users can use either xml file(orm.xml,
I have an XLST file that is supposed to parse an XML file and
Suppose i want to open an xml file which i have in my email
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily
Suppose I have a table called Companies that has a DepartmentID column. There's also
I'd like to use a custom PMD ruleset file for my build. Basically, I
I have started with the project where I am suppose to use client side

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.