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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:00:06+00:00 2026-05-16T11:00:06+00:00

Which XML structure allows me faster adding,deleting,updating of a node? My assumption is the

  • 0

Which XML structure allows me faster adding,deleting,updating of a node?

My assumption is the first one as the xml hierarchy is not that deep.

What do you think ?

<Departments>
   <Department Id="a Guid" IsVisible="True" />
</Departments>

OR

<Departments>
   <Department>
      <Id>a Guid</Id>
      <IsVisible>True</IsVisible>
   </Department> 
</Departments>
  • 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-16T11:00:07+00:00Added an answer on May 16, 2026 at 11:00 am

    In general

    In general terms I tend to agree with the other answers here, but I’d like to add a few remarks. Performance is normally most hindered by its slowest factor, which is the network, the database connection, the file system or even the internal memory when I/O is part of the issue. If we take that as a given, a possible conclusion is that the smaller the size, the bigger the performance improvement is.

    Other factors

    But there’s another factor. Attributes and elements are implemented differently. Attributes are implemented something like key/value pairs with a uniqueness constraint and roughly take the size of chars * 2 + sizeof(int). Elements require a much larger structure in-memory and for the sake of brevity, I like to use one simple factor that’s some average between several implementations: 3.5 * chars. I use chars here, because whether you store it as UTF8 or as UTF16 makes a storage difference, but not an in-memory difference.

    The former paragraph implies that attributes are faster. But still this isn’t a simple fact, because attributes are not implemented as normal nodes and searching for their data is generally slower than searching for data in nodes. This is hard to measure in general terms and requires profiling for every particular situation to find out.

    LINQ

    Then there’s LINQ. If you use LINQ, reading and writing is done with streaming XML which is relatively fast. The in-memory representation is usually much smaller and much faster than with XmlDocument parsing.

    Names

    The size of the names of the fields, like elements and attributes does not matter. Internally they are keyed and given a unique ID. The contents of the elements and the attributes, however, will add to the overall memory footprint.

    If the size of the names is very large compared to their content, minifying the names will make your XML less readable, but also requires less I/O or network bandwidth. As such, in some cases, it may improve performance to use small names.

    UTF-8 or UTF-16

    Finally, I should add a note on the way you store it. Common sense says, store it as UTF-8. But that requires the parser to read each character and transform it in-memory to UTF-16. This costs time. Sometimes, a larger size of the file (for using UTF-16) can outperform a smaller size (with UTF-8) because the processor overhead is too big. Again, measuring your performance in several scenarios can help. Oh, and if you use a lot of (very) high characters, UTF-16 should be the preferred choice, because UTF-8 may use 3, 4 or even 6 bytes per character.

    Summary

    To sum it up, if speed is imperative and you cannot resort to a binary format:

    • Prefer attributes over elements, but only if DOM use is anticipated and searching / keying is not too important;
    • Prefer UTF-8 over UTF-16 only when the files are very large and you use few (very) high characters, measure to find out;
    • Prefer streaming over DOM for all your uses (LINQ typically uses streaming);
    • Don’t bother using small names unless your I/O is really a bottleneck and the factor data:overhead is very large;
    • Define a few typical usage scenarios and measure;

    PS: the above is what comes to mind when thinking about XML, there may, of course, be many other factors the improve / degrade performance, the largest perhaps your own skills in writing the best procedures for your CRUD operations.

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

Sidebar

Related Questions

I'm working with an existing XML document which has a structure (in part) like
We utilise a third party web service that returns XML which looks something like
Which XML validation tools can you recommend for both performance and accuracy, each of
The server.xml which controls the startup of Apache Tomcat's servlet container contains a debug
I have a xml which is max 3 levels deep. Now by using C#
Below is part of the XML which I am processing with PHP's XSLTProcessor :
I have an AppleScript program which creates XML tags and elements within an Adobe
I have a Java servlet which generates XML, translates it with an XSLT stylesheet,
We have a Perl program to validate XML which is invoked from a Java
Have recently been given a project to complete which uses XML quite extensively.Am looking

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.