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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:07:15+00:00 2026-05-28T05:07:15+00:00

I have an xml file with 3 pieces of data per item: productName, productCode

  • 0

I have an xml file with 3 pieces of data per item: productName, productCode and productPrice. The number of items in the xml file is around 7,000.

User can search for product by name by typing “red shirt” for example in a textbox.
My code does these tasks:

  1. tokenize the search text and collect productName’s that contains ALL of the search words.

  2. order the selection by productCode

  3. select for display only productName and productPrice (not productCode which is used only for orderby)

  var products = from d in xElem.Descendants(fileName)
                        where textBox1.Text.ToLower().Split(' ').All(t => d.Element(productName).Value.ToLower().Contains(t))

                        orderby d.Element(productCode).Value ascending
                        select new
                        {
                            Price = (double.Parse(d.Element(productPrice).Value)).ToString(numberFormat),
                            Name = d.Element(Name).Value
                        };

Where in this code are the bottleneck(s)? And how to remove them?
I do this Linq select every time a keystroke is entered in the textbox, meaning realtime result update (vs. waiting for the Enter key).
Thanks.

  • 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-28T05:07:16+00:00Added an answer on May 28, 2026 at 5:07 am

    Without attaching a profiler and seeing the output I can only guess what is slow.

    1. where textBox1.Text.ToLower.Split(' ') can be cached outside the query. I doubt this is a serious issue though.

    2. LINQ to XML can be slow on very large XML documents. Consider using XmlTextReader for fast (but ugly) access to underlying XML in a forward-only manner.

    3. Preprocess the data in memory if the XML is amenable to that. In memory queries should be pretty fast.

    4. You can use something like Lucene.Net to index a large quantity of XML files for quick searching. This might be overkill but it’s pretty fast and scalable.

    5. Think about the problem a bit more. Every time the user presses a key you’re processing the XML DOM and doing a bunch of string operations. Processing the XML such that you have a form more suitable to your task seems like a good win.

    Note that the response time for autocomplete of this nature is pretty lax, up to a second of lag or so is pretty acceptable for most purposes.

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

Sidebar

Related Questions

My app uses XML to save user data to a file. I have just
I am trying to access certain pieces of data from an xml file, here
I have a bunch of hierarchical data stored in an XML file. I am
I have a piece of data. At the moment, it's an XML file, but
I have the following piece of code to write data to an XML file.
I have a Windows Phone app that relies on an XML data file that
I have xml file with such structure: ... <outer> ... <inner/> ... </outer> ...
What is the easiest way to convert xml to html? I have xml file
I have an XML file from which I am parsing some content to display
I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>

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.