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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:44:35+00:00 2026-05-18T07:44:35+00:00

I am writing code that parses XML. I would like to know what is

  • 0

I am writing code that parses XML.

I would like to know what is faster to parse: elements or attributes.

This will have a direct effect over my XML design.

Please target the answers to C# and the differences between LINQ and XmlReader.

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-18T07:44:35+00:00Added an answer on May 18, 2026 at 7:44 am

    With XML, speed is dependent on a lot of factors.

    With regards to attributes or elements, pick the one that more closely matches the data. As a guideline, we use attributes for, well, attributes of an object; and elements for contained sub objects.

    Depending on the amount of data you are talking about using attributes can save you a bit on the size of your xml streams. For example, <person id="123" /> is smaller than <person><id>123</id></person> This doesn’t really impact the parsing, but will impact the speed of sending the data across a network wire or loading it from disk… If we are talking about thousands of such records then it may make a difference to your application.

    Of course, if that actually does make a difference then using JSON or some binary representation is probably a better way to go.

    The first question you need to ask is whether XML is even required. If it doesn’t need to be human readable then binary is probably better. Heck, a CSV or even a fixed-width file might be better.

    With regards to LINQ vs XmlReader, this is going to boil down to what you do with the data as you are parsing it. Do you need to instantiate a bunch of objects and handle them that way or do you just need to read the stream as it comes in? You might even find that just doing basic string manipulation on the data might be the easiest/best way to go.

    Point is, you will probably need to examine the strengths of each approach beyond just “what parses faster”.

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

Sidebar

Related Questions

I'm writing some code that handles logging xml data and I would like to
I find myself writing code that looks like this a lot: set<int> affected_items; while
I'm writing code where I retrieve XML from a web api, then parse that
i have php function that parses a xml url and gives me an array.this
Basically I have an XML file that looks like this: <?xml version=1.0 encoding=UTF-8?> <data>
I'm writing code that looks similar to this: public IEnumerable<T> Unfold<T>(this T seed) {
I am writing code that will deal with currencies, charges, etc. I am going
I am writing code that will spawn two thread and then wait for them
I am writing code that catches this OutOfMemoryException and throws a new, more intuitive
I'm writing some code that id like to be able to work with any

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.