[whatwg] Requesting JSON.toXML

hi
1/ Looking at the example below and the "I'd like to skip the population 
of a DOM via: for(var i in obj) { dom.appendChild(i);.... }; " from mail 
in this thread, you have certain nativity about XML... the element does 
not only have content, but also attributes, so each element would have 
to have 2 properties (attribs as object and content), there does not 
have to be 1 content, there can be multiple nodes, nodes can be text, 
element, comment, CDATA, processing instruction, there can be inline DTD 
specificication, there can be namespaces involved... could you actually 
imagine generating such content on server side if we are really 
discussing XML and not only some element+text subpart? Sure one can 
argue that "once browser would know such function to parse it, server 
side languages would implement serializing" but the question is why? 
What would we accomplish? Literally nothing.

JSON is for describing data, XML for describing document... attemps to 
manage data using XML (like wsdl) ended up in mess, because XML is not 
meant for that... and JSON is not meant for document definition...

Basically you will end up with very messy document 
definition/description in language that was never meant to be used like 
this with 1 results: it is completely useless (maybe with 1 "magic" 
implementation you are suggesting); regular XML parsers unable to parse 
it and JSON parsers probably parsing it but generating some kind of 
pseudo structure not really describing object as data type in easy and 
generic format = essentially loosing the strength of both formats.

I know JSON is cool (trust me, after discovering JSON years ago I felt 
the same and I still feel :) ), but I suggest reconsidering your 
application design and using tools for what they are meant to be used, 
because your suggestion is not introducing new functionality nor you are 
simplifying common task.


Brona

On 30.9.2011 23:19, Charles Pritchard wrote:
> Now that DOM4 includes DOMString as an argument type for Node methods, I'd like to have a clear and easy path to serialize a JSON object into an XML DOMString.
>
> It's not a trivial task. Any takers?
>
> Example:
>
> JSON.toXML({div:'Hello world'});
>
> -Charles
>
>

Received on Friday, 30 September 2011 21:44:26 UTC