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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:56:52+00:00 2026-05-13T11:56:52+00:00

Possible Duplicate: Should I use Elements or Attributes in XML? I have never been

  • 0

Possible Duplicate:
Should I use Elements or Attributes in XML?

I have never been able to figure out when to use xml attributes. I always use elements. I just read this w3schools article. The article states that it is bad practice to use attributes because:

  • attributes cannot contain multiple values (child elements can)
  • attributes are not easily expandable (for future changes)
  • attributes cannot describe structures (child elements can)
  • attributes are more difficult to manipulate by program code
  • attribute values are not easy to test against a DTD

The only exception that it states is when you are assigning an id to a tag.

Is this correct? Why do attributes even exist then? Was it a design error with xml? Is there something I am missing here?

The only reason I could think of for using attributes would be for one to one relationships. ie: name. But it would have to be a one to one relationship to something that is a primitive (or string). Because it would be important that in the future you would not want to break it up into several differnt sections. ie:

<date> May 23, 2001 </date>

to:

<date>
   <month> May </month>
   <d> 23 </d>
   <yr> 2001 </yr>
</date>

Because this would not be possible with an attribute.

Bonus question: In the date example would it be possible to do something like this:

<date>
   <default> May 23, 200 </default>
   <month> May </month>
   <d> 23 </d>
   <yr> 2001 </yr>
</date>

To give future applications more (or different) information while still offering existing apps the same format? Or would you have to do this:

<date> May 23, 2001 </date>
<NEWdate>
   <month> May </month>
   <d> 23 </d>
   <yr> 2001 </yr>
</NEWdate>
  • 1 1 Answer
  • 1 View
  • 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-13T11:56:53+00:00Added an answer on May 13, 2026 at 11:56 am

    Attributes are good when you want to attach information to other information, perhaps to describe how the information should be interpreted. For example:

    <speed unit="mph">65</speed>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Should I use Elements or Attributes in XML? I'm writing a configuration
Possible Duplicate: Why should I use templating system in PHP? I was just curious
Possible Duplicate: Why should I use a thread vs using a process? I have
Possible Duplicate: When should you use 'friend' in C++? I have come to a
Possible Duplicate: Should I Use self Keyword (Properties) In The Implementation? Say I have
Possible Duplicate: When should I use require_once vs include? For example if I have:
Possible Duplicate: What data-structure should I use to create my own “BigInteger” class? Out
Possible Duplicate: Should I use != or <> for not equal in TSQL? Behavior
Possible Duplicate: When should one use final? When should Java programmers prefer to use
Possible Duplicate: Tasks should show up only if the user has been assigned it

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.