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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:50:47+00:00 2026-05-24T07:50:47+00:00

Is there a fast way to clear the previous content of an MSXML2.DOMDocument object

  • 0

Is there a fast way to clear the previous content of an MSXML2.DOMDocument object prior to reuse? I’ve been in the habit of discarding them and creating a fresh instance each time but this strikes me as wasteful and profiling a few test cases seems to confirm this.

I’m sticking with MSXML 3.0 in this case for portability, and I realize this older version has some quirks when it comes to using XPath to select large sets of nodes. Trying to select the whole document tree and then removing it doesn’t feel clean and doesn’t run as fast as I’d like. The “lazy selection” MSXML 3.0 uses doesn’t inspire confidence either:

selectNodes Method

Previously, in MSXML 3.0 and earlier versions, the selection object created by calling the selectNodes method would gradually calculate the node-set. If the DOM tree was modified, while the selectNodes call was still actively iterating its contents, the behavior could potentially change the nodes that were selected or returned. In MSXML 4.0 and later, the node-set result is fully calculated at the time of selection. This ensures that the iteration is simple and predictable. In rare instances, this change might impact legacy code written to accommodate previous behavior.

I also realize that reusing such an object requires being mindful of the current settings of different properties (SelectionLanguage, etc.) that might linger between uses. I’d think that shouldn’t be a big deal though, especially if the reusage always follows the same pattern.

I suppose what I’m after then is some clean and fast way to clear the loaded DOM to reuse it, or more input as to why reuse might be worse than the alternative of recreation.

  • 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-24T07:50:47+00:00Added an answer on May 24, 2026 at 7:50 am

    You may consider migrating to MSXML6:

    1. First of all, MSXML6 is in-the-box with WinXP SP3, Vista, Windows
      Server 2008, Win7 and Windows Server 2008 R2. The only OS supported
      by Microsoft that doesn’t have MSXML6 in band is Windows 2003, where
      you’ll have to let customer to download the MSI. Overall, MSXML6 is
      almost as portable as MSXML3.
    2. Unlike MSXML3 supporting both XSL Pattern and XPath, MSXML6 supports XPath only, where SelectNodes and SelectSingleNode only work in the context of snapshot.
    3. Unlike GetElementsByTagName, a snapshot semantics is a defined by W3C.
      MSXML6 has better performance and W3C compliance.

    Also, you shouldn’t care too much about cleaning up the document after each use, as MSXML has Garbage Collection internally, meaning you’ll not get the memory back when you replacing the document element. My advice is to have peace with a specific cleansing effort, just reuse the instance for the next load or rebuilding the tree with DOM API. If memory usage is really a big concern, XmlLite can give you full control.

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

Sidebar

Related Questions

Is there a fast way of checking if an object is a jQuery object
i was wondering if there is a fast way to clear cache on a
Is there any fast way, or do I have to convert manually them? Thanks.
Is there a fast/efficiency way to check if a table is empty? DECLARE @StartEndTimes
I need to check in some fast way if there is any text nodes
Is there a fast way to do that?
Is there a fast way to make headers public when setting up a Framework
Is there a fast way to convert numbers with exponential notation (examples: 0.5e10 or
Is there a fast way in the Address Book framework on the iOS platform
Is there a fast way to search for string in another string? I have

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.