- From: Mark Robinson <markr@sites-online.com>
- Date: Fri, 16 Oct 1998 13:58:05 -0400
- To: www-dom@w3.org
Recently downloaded the DOM 1.0 spec and have a few basic questions
which I'm hopeful you'll indulge:
1) Where can I find the DOM FAQ?
(Using the sample provided on pgs 10-11 of the spec and treating the
?elements? as xml, i.e. not considering the appropriate html interfaces)
2) Is the root node "<TABLE>" or is "<TABLE>" the first child node of
the document?
3) Finally, the spec says NodeList "contains all children of this
node". That would seemingly include grandchildren, right? If that's
the case, and I just want to print out a document equivilent to the
original, how can I tell where the end tags need to be printed?
I'd expected to be able to do something like this...
...
dumpNode( doc );
public String dumpNode( Node n )
{
if( n instanceof Element ) // or use getNodeType()
{
System.out.println( "<" + n.getNodeName() + ">" );
NodeList nl = n.getChildNodes();
int childPtr = 0;
Node n2 = nl.item( childPtr )
while( n2 != null )
{ dumpNode( n2 );
childPtr++;
n2 = n1.item( childPtr );
}
System.out.println( "<//" + n.getNodeName() + ">" );
}
else if ( n instanceof Text )
{ System.out.println( ((Text) n).getData() );
}
}
Thanks,
Mark Robinson
Received on Friday, 16 October 1998 13:59:25 UTC