Badgerfish Convention
This convention is used to provide the means to translate between XML and JSON without losing any data (that is, namespaces).
1. Element names become object properties.
2. Text content of elements goes in the $ property of an object.
3. Nested elements become nested properties.
4. Multiple elements at the same level become array elements.
5. Attributes go in properties whose names begin with @.
6. Active namespaces for an element go in the element's @xmlns property.
7. The default namespace URI goes in @xmlns.$.
8. Other namespaces go in other properties of @xmlns.
9. Elements with namespace prefixes become object properties, too.
Simple example:
<price xmlns="http://acme.com">10.00</price>
{ "price": { "@xmlns": { "$": "http://acme.com" }, "$1": "10.00" } }
A more complex example:
<alice xmlns="http://some-namespace"
xmlns:charlie="http://another-namespace">
<bob>david</bob>
<charlie:edgar>frank</charlie:edgar>
</alice>
{ "alice" : { "bob" : { "$" : "david" , "@xmlns" :
{"charlie" : "http://another-namespace" , "$" : "http://some-namespace"} } ,
"charlie:edgar" : { "$" : "frank" , "@xmlns" :
{"charlie":"http://another-namespace", "$" : "http://some-namespace"} },
"@xmlns" : { "charlie" : "http://another-namespace", "$" : "http://some-nam
espace"} } }