W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2011

[whatwg] Requesting JSON.toXML

From: Charles Pritchard <chuck@jumis.com>
Date: Fri, 30 Sep 2011 14:58:13 -0700
Message-ID: <4E863B75.2080904@jumis.com>
On 9/30/11 2:23 PM, Tab Atkins Jr. wrote:
> On Fri, Sep 30, 2011 at 2:19 PM, Charles Pritchard<chuck at jumis.com>  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'});
> I'm curious why you would want such a thing.  You can store DOM trees
> as strings and revive them when used.  You can transmit DOM across XHR
> either as a string or, soon, directly as a document.
> I don't see a reason to store DOM into an alternative JSON structure.
FWIW, it's meant for the other direction: converting a JSON structure 
into DOM (or XML).

If a JSON.toNode (document fragment) makes more sense, that'd work too 
and may be more efficient.

JSON.toNode({div: 'hello world'}).toString() would give me XML,
and without the toString, I'd have a node, which is now the same as 
document fragment.
Received on Friday, 30 September 2011 14:58:13 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:36 UTC