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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:08:00+00:00 2026-05-28T14:08:00+00:00

What is the fastest method to retrieve an XML node? I have an application

  • 0

What is the fastest method to retrieve an XML node? I have an application that need the functionality of replace a specific node, when the document is small is fast but soon get bigger then it takes some several second to do the replacement. This is the method, I just do a brute force comparison that sucks real bad in that scenario.

public bool ReplaceWithAppendFile(string IDReplace)
{
    XElement UnionElement = (from sons in m_ExtractionXmlFile.Root.DescendantsAndSelf()
                             where sons.Attribute("ID").Value == IDReplace
                             select sons).Single();
    UnionElement.ReplaceWith(m_AppendXmlFile.Root.Elements());
    m_ExtractionXmlFile.Root.Attribute("MaxID").Value =
        AppendRoot.Attribute("MaxID").Value;
    if (Validate(m_ExtractionXmlFile, ErrorInfo))
    {
        m_ExtractionXmlFile.Save(SharedViewModel.ExtractionFile);
        return true;
    }
    else
    {
        m_ExtractionXmlFile = XDocument.Load(SharedViewModel.ExtractionFile);
        return false;
    }
}
  • 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-28T14:08:01+00:00Added an answer on May 28, 2026 at 2:08 pm

    Try using XPath:

    string xPath = string.Format("//*[@id='{0}']", IDReplace);
    XElement UnionElement = m_ExtractionXmlFile.XPathSelectElement(xPath);
    

    You may refer to Finding Elements by Attributes in a DOM Document Using XPath for more examples.

    P.S. It is considered good convention to start names of parameters and local variables in lowercase. Thus, use idReplace and unionElement rather than the above.

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

Sidebar

Related Questions

What is the fastest method of parsing an XML file in C#? I'm using
Possible Duplicate: Fastest method to replace all instances of a character in a string
What's the fastest method , to remove a specific extension from a String by
What would be the fastest, most efficient way to implement a search method that
Given a string s , what is the fastest method to generate a set
What is the fastest way to execute a method on an ASP.NET website? The
Using SQL Server, which is the fastest or best practice method to use for
I am in search for an efficient method to replace a couple of DOM
I have a form class with a method: IText getSearchField() The IText interface is
What is the single fastest method for table row hover css change? I've tried

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.