Hi all, I failed to understand how DOM models whitespace before the document element. E.g. in the following fragment, the white space between the XML declaration and the starting tag of the <root> element: <?xml version="1.0" encoding="UTF-8"?> <root> <child /> </root> When I parse such a document and get the DOM objects using DocumentBuilder (in java), then later write the objects back to a file using Transformer, the whitespace is preserved. But I cant see the object responsible for the whitespace in the DOM object tree. And also, when I try to insert a text element before the document element I get an exception indicating "HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted." This is consistent with DOM level1 spec, as text nodes dont seem to This means that I cant insert whitespace before the document element when I'm programmatically creating the document, and my document becomes: <?xml version="1.0" encoding="UTF-8"?><root> <child /> </root> Though identical in semantics, it does not look very good and readable. Any ideas or knowledge on this? Thanks in advance, guvenReceived on Thursday, 20 March 2008 04:23:39 GMT
This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 October 2009 08:24:59 GMT