This would balance the method -(void)loadData which loads a file from data. Currently, this requires getting a string from the documentElement and converting it to data. This loses the DTD and XML declarations if present. Consequently mthods to roundtrip load data and save data are not there.
It is correct that document.documentElement serialization does not include the DTD or XML declaration, but I believe that serialization of the document itself should include those, and I think it's a WebKit bug that it doesn't. Try javascript:alert((new XMLSerializer).serializeToString(document)) in Safari and in Firefox to compare the results.
reported to http://bugreport.apple.com/ as 4995330
> It is correct that document.documentElement serialization does not include the > DTD or XML declaration, but I believe that serialization of the document itself > should include those, and I think it's a WebKit bug that it doesn't. Just to clarify, this bug is referring to the WebFrame class that has a corresponding element to loadData, but not one to unload data that has been edited. A related bug that should probably be reported separately is that there is no method to serialize the document that preserves the original DocType and XML preambles ( if any).