Re: doctype declaration

Don't assume that Document.getFirstChild is any particular kind of node.
The DocumentType node may preceed the document's root element, if present.
There may also be comments or PIs preceeding or following the root element.
And in some DOMs, there may be a node for the XML Declaration, if you're
working in XML.

If you want to retrieve the root node (<HTML>, in your case), the best
solution is to use the call specifically designed for that purpose --
Document.getDocumentElement(). Second best is to walk through the
Document's children looking for a node whose type is Element.

______________________________________
Joe Kesselman  / IBM Research

Received on Monday, 10 July 2000 12:49:13 UTC