javascript - Origin of the "@attributes" element in JSON generated from XML -


how and/or in conventions xml attributes put in object named "@attributes" when converting xml json? style used in this generic xml parser:

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

..to create json this:

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

i'm not looking answers element-centric vs. attribute-centric xml design, unless things more closely related question thought of course. ;)

where did @attributes notation come , there reasons use on using own notation?

thanks!

it evolved xpath @attribute syntax

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

using @ makes recognisable people used xpath

example: xpath : nodes child node contains attribute


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -