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
Comments
Post a Comment