Origin of the “@attributes” element in JSON generated from XML

graffin

New Member
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:\[code\]obj["@attributes"] = {};for (var j = 0; j < xml.attributes.length; j++) { var attribute = xml.attributes.item(j); obj["@attributes"][attribute.nodeName] = attribute.nodeValue;}\[/code\]..to create JSON like this:\[code\]...elem_array = [ { "@attributes": { an-attribute: "", another-one: "mr.text" } }]...\[/code\]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!
 
Back
Top