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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:53:16+00:00 2026-05-15T08:53:16+00:00

I know the elements versus attributes debate has come up many times here and

  • 0

I know the elements versus attributes debate has come up many times here and elsewhere (e.g. here, here, here, here, and here) but I haven’t seen much discussion of elements versus attributes for simple property values.

So which of the following approaches do you think is better for storing a simple value?

A: Value in Element Content:

<TotalCount>553</TotalCount>
<CelsiusTemperature>23.5</CelsiusTemperature>
<SingleDayPeriod>2010-05-29</SingleDayPeriod>
<ZipCodeLocation>12203</ZipCodeLocation>

or B: Value in Attribute:

<TotalCount value="553"/>
<CelsiusTemperature value="23.5"/>
<SingleDayPeriod day="2010-05-29"/>
<ZipCodeLocation code="12203"/>

I suspect that putting the value in the element content (A) might look a little more familiar to most folks (though I’m not sure about that).

Putting the value in an attribute (B) might use less characters, but that depends on the length of the element and attribute names.

Putting the value in an attribute (B) might be more extensible, because you could potentially include all sorts of extra information as nested elements. Whereas, by putting the value inside the element content (A), you’re restricting extensibility to adding more attributes. But then extensibility often isn’t a concern for really simple properties – sometimes you know that you’ll never need to add additional data.

Bottom line might be that it simply doesn’t matter, but it would still be great to hear some thoughts and see some votes for the two options.

  • 1 1 Answer
  • 3 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-15T08:53:16+00:00Added an answer on May 15, 2026 at 8:53 am

    I’m not sure this is worth a poll. Option B is obviously wrong. It uses redundant information, and will be difficult to validate using XML schema.

    The general “debate” is about whether to use your option A or something like this:

    <Measurements totalCount="553" 
                  celsiusTemperature="23.5"
                  singleDayPeriod="2010-05-29"
                  zipcodeLocation="12203"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to get elements with a particular attribute : $("#para [attr_all]") But
I know that I should put all the html elements in body tag, but
I have got an array, I know how to count its elements, but I
Just wondering if there's an easy way to know how many elements are contained
Does anyone know how many elements a jQuery accordion can handle before performance becomes
I have 4 files and would like to know elements which are non overlapping
I know that the UI elements (View hierarchy) may only be manipulated from the
Do you know how to select elements which id DOES NOT contain a given
I would like to know how to read elements from a const boost::multi_array object.
I would like to know how I can add ImageView Elements to a Region

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.