Re: How can DOM possibly contain a document?

>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 UTC