[whatwg] DOM3 Load and Save for simple parsing/serialization?

Brett Zamir brettz9 at yahoo.com
Mon May 18 05:45:18 PDT 2009


One more thought...

While it is great that innerHTML is being officially standardized, I'm 
afraid it would be rather hackish to have to use it for parsing and 
serializing dynamically created content which wasn't destined to make it 
immediately into the document, if at all.

Has any thought been given to standardizing on at least a part of DOM 
Level 3 Load and Save in HTML5?

The API, if simply applied to serialization, would look like this :

     var ser = DOMImplementationLS.createLSSerializer();
     var str = ser.writeToString(document);

and like this for parsing to the DOM:

     var lsParser = DOMImplementationLS.createLSParser(1, null); // 1 
for synchronous; null for no schema type
     var lsInput = DOMImplementationLS.createLSInput();
     lsInput.stringData = '<myXml/>';
     var doc = lsParser.parse(lsInput);

If a revision to the DOM3 module is not in order (which, e.g., 
simplifies the parsing from a string for simple cases) and the above is 
considered too cumbersome, maybe some other cross-browser standard could 
be agreed upon?

I think using DOM3 would facilitate readily adding additional aspects of 
the module in the future (as ECMAScript seems to be positively albeit 
slowly expanding to ever new uses) and offer familiarity for those 
working in other contexts with DOM Level 3, while ECMAScript users can 
still wrap these in their own simpler functions. However, I can also see 
the desire for something simpler (as I say, maybe an addendum to the L&S 
module). But I do hope something might be considered, since I find this 
to be a quite frequent need and do not like relying on feature-checking 
for non-standard methods in the various browsers as well as being 
unclear on how to future-proof my code to work with standards-compliant 
browsers...

thanks,
Brett



More information about the whatwg mailing list