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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:19:26+00:00 2026-06-05T05:19:26+00:00

How and/or in which conventions are XML attributes put in an object named @attributes

  • 0

How and/or in which conventions are XML attributes put in an object named “@attributes” when converting XML to JSON? This style is used in this generic XML parser:

obj["@attributes"] = {};
for (var j = 0; j < xml.attributes.length; j++) {
  var attribute = xml.attributes.item(j);
  obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
}

..to create JSON like this:

...
elem_array = [
  {
    "@attributes": {
      an-attribute: "",
      another-one: "mr.text"
    }
  }
]
...

I’m not looking for answers about element-centric vs. attribute-centric XML design, unless those things are more closely related to my question than I thought of course. 😉

Where did the @attributes notation come from and are there reasons to use it over using your own notation?

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-06-05T05:19:27+00:00Added an answer on June 5, 2026 at 5:19 am

    it is likely evolved from the XPATH @attribute syntax

    http://www.tizag.com/xmlTutorial/xpathattribute.php

    Using the @ makes it recognisable to people used to XPATH

    Example: XPath : Get nodes where child node contains an attribute

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

Sidebar

Related Questions

I have this JSON (which validates according to JSONLint ): [ { "BugCount":"2", "BugTitle":"C:\\INETPUB\\WWWROOT\\CLUBREADY2\\TRAINERS\\../Connections/LTC.asp",
I have a project which does not follow the rails nameing conventions, because it
We need to use a web service which communicates extremely ugly XML. It is
I'm creating XML file which will hold couple of values regarding TCP Connection (IP
I am receiving an XML document from a REST service which shall be parsed
I'm reading in an XML file from an XMLReader class, which I create and
I'm supposed to be using a web service function which has an XML parameter.
My application serializes data into various XML attributes, and depending on data it might
I have a XML file which holds configuration data for data sources, and the
Eclipse WTP creates its own server.xml file which it places in some folder which

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.