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

The Archive Base Latest Questions

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

What is the difference in processing speed for executing a process using XML manipulation

  • 0

What is the difference in processing speed for executing a process using XML manipulation or using object-oriented representation? In general, is it faster to maximize or minimize the reliance on XML for a process. Let it be assumed that the code is highly optimized in either circumstance.

A simple example of what I am asking is which of the following would execute faster, when called from a C# web application, if the Thing in question were to represent the same qualified entity.

  //                            XSL CODE FRAGMENT
  <NewThings>
     <xsl:for-each select="Things/Thing">
        <xsl:copy-of select="." />
     </xsl:for-each>
  </NewThings>

or

  //                                C# Code Fragment
  void iterate(List<Thing> things){
      List<Thing> newThings = new List<Thing>();
      things.ForEach(t=>newThings.Add(t));
  }

A complex example of might be whether it is faster to manipulate a system of objects and functions in C# or a system of xml documents in an XProc pipeline.

Thanks a lot.

  • 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-15T16:12:08+00:00Added an answer on May 15, 2026 at 4:12 pm

    Generally speaking, if you’re only going to be using the source document’s tree once, you’re not going to gain much of anything by deserializing it into some specialized object model. The cost of admission – parsing the XML – is likely to dwarf the cost of using it, and any increase in performance that you get from representing the parsed XML in something more efficient than an XML node tree is going to be marginal.

    If you’re using the data in the source document over and over again, though, it can make a lot of sense to parse that data into some more efficiently-accessible structure. This is why XSLT has the xsl:key element and key() function: looking an XML node up in a hash table can be so much faster than performing a linear search on a list of XML nodes that it was worth putting the capability into the language.

    To address your specific example, iterating over a List<Thing> is going to perform at the same speed as iterating over a List<XmlNode>. What will make the XSLT slower is not the iteration. It’s the searching, and what you do with the found nodes. Executing the XPath query Things/Thing iterates through the child elements of the current node, does a string comparison to check each element’s name, and if the element matches, it iterates through that element’s child nodes and does another string comparison for each. (Actually, I don’t know for a fact that it’s doing a string comparison. For all I know, the XSLT processor has hashed the names in the source document and the XPath and is doing integer comparisons of hash values.) That’s the expensive part of the operation, not the actual iteration over the resulting node set.

    Additionally, most anything that you do with the resulting nodes in XSLT is going to involve linear searches through a node set. Accessing an object’s property in C# doesn’t. Accessing MyThing.MyProperty is going to be faster than getting at it via <xsl:value-of select='MyProperty'/>.

    Generally, that doesn’t matter, because parsing XML is expensive whether you deserialize it into a custom object model or an XmlDocument. But there’s another case in which it may be relevant: if the source document is very large, and you only need a small part of it.

    When you use XSLT, you essentially traverse the XML twice. First you create the source document tree in memory, and then the transform processes this tree. If you have to execute some kind of nasty XPath like //*[@some-attribute='some-value'] to find 200 elements in a million-element document, you’re basically visiting each of those million nodes twice.

    That’s a scenario where it can be worth using an XmlReader instead of XSLT (or before you use XSLT). You can implement a method that traverses the stream of XML and tests each element to see if it’s of interest, creating a source tree that contains only your interesting nodes. Or, if you want to get really crazy, you can implement a subclass of XmlReader that skips over uninteresting nodes, and pass that as the input to XslCompiledTemplate.Transform(). (I suspect, though, that if you knew enough about how XmlReader works to subclass it you probably wouldn’t have needed to ask this question in the first place.) This approach allows you to visit 1,000,200 nodes instead of 2,000,000. It’s also a king-hell pain in the ass, but sometimes art demands sacrifice from the artist.

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

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer According to the Microsoft Visual Studio page on Wikipedia, in… May 16, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer Well, your code that "works" appears to look at StartTime… May 16, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer If you want to force SSL the best way to… May 16, 2026 at 5:07 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Currently the my team is considering splitting our single CI build process into a
I am working on a SQL Job which involves processing around 75000 records. Now,
I've my own class which should do the request and the data processing (parsing).
I am using Installshield, and have had success in launching my exe install files
If givin some situation that you can do a loop of a certain event
I need to separate multiframe tiff files, and use the following method: public static
I'm developing an rss feed reader that uses a bayesian filter to filter out
I have a big query and I am tring to improve it part by
I am starting my first independent for profit venture. I am having a hard
I'm iterating through an array and sorting it by values into days of the

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.