On Thu, 2003-12-11 at 12:20, Henrik Johansson wrote: > Is it possible to preserve the structure from an input file when > serializing its DOM-tree to an output file? > > Example: > --- > <book> <title> > The Clue > </title> > <chapters> > 13 > </chapters> > </book>
Well, the "book" element has the following children: * a text node containing one space * a title element * a text node containing a linefeed and about 10 spaces * a chapter element * a text node containing a linefeed and about 5 spaces. The title element has one child, being a text node containing a linefeed, about 10 spaces, "The Clue", a linefeed and another 10 spaces. etc. So provided you do *not* have a schema which specifies that <book> is of "element content only", and you serialize without "pretty-printing", I would expect that you would get back something pretty similar when you serialize the dom back out again. Note however that, in general, xml parsers don't preserve input formatting. Most xml parsers (including xerces) provide no mechanism for preserving xml attribute order for example, because attribute order is not meaningful in xml. There are some posts on this subject in the email archives, particularly from people trying to write xml/xslt editing programs. I don't know what solution (if any) they came up with to this issue. Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
