W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2000

Re: How can DOM possibly contain a document?

From: <keshlam@us.ibm.com>
Date: Thu, 23 Mar 2000 00:02:20 -0500
To: Bernard Miller <thatsmrberns2u@yahoo.com>
cc: www-dom@w3.org
Message-ID: <852568AB.001BA95E.00@D51MTA03.pok.ibm.com>
>I'm having a hard time understanding how one can use
>any combination of DOM functionality to reconstruct a
>document with nested tags.

The DOM doesn't yet provide a function which does this, but there are
_MANY_ examples of such programs --  one such is the DOMWriter example
included with XML4J and Xerces (IBM and Apache, respectively). Basically,
you have to walk the DOM tree and print each node using the appropriate
syntax.

DOM Level 3's Load/Save module will provide a standardized version of this.

>as far as I can tell you can query the
>parent for WHAT the child is, and in what order the
>child appears among other children, but not WHERE it
>is in the text of the parent.

I'm not sure what question you're asking here.  If you know what the type
of the node is, then you know where its children appear -- for example,  if
you have an Element node, you know that you have to retrieve its name and
its attributes to generate and print the start-tag, then print out its
children (they appear in document order, so this is easy), then print the
end-tag. Doing this recursively is pretty trivial; doing it nonrecursively
is a trifle harder but more efficient.

If that doesn't answer your question, I think I need a more specific
example so I can see what's confusing you...

______________________________________
Joe Kesselman  / IBM Research
Received on Thursday, 23 March 2000 00:02:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:47 GMT