W3C home > Mailing lists > Public > html-tidy@w3.org > January to March 2001

Re: tidy - ? html tree number

From: Chunbo Shao <cxs0187@omega.uta.edu>
Date: Mon, 8 Jan 2001 14:13:14 -0600 (CST)
To: Gary L Peskin <garyp@firstech.com>
cc: html-tidy@w3.org, lempinen@iki.fi, ac.quick@sympatico.ca
Message-ID: <Pine.OSF.4.10.10101081332400.12098-501000@omega.uta.edu>
Hi, Gary

Many many thanks to your kind help. I attach my files to you. Actually, i
just use the example java file TestDOM class in "jtidy.html" which is from
the tidy package. My html file is out0.html. "resu" is the output by
running "java TestDOM out0.html > resu". Please see the "resu" file and
"out0.html", the "len" for <html> is 1, not 2. But it should be 2. Because
it has <head> and <body> in "out0.html". And, the "len" for <head> in
"resu" is 1, not 3. But it should be 3 because <meta>, <script> and
<title> are 3 children of <head> in "out0.html".

I download the new tidy package from http://lempinen.net/sami/jtidy/ and
use it to compile TestDOM.java.

And also, when i go to see the
TreeViewer(http://xml.apache.org/xerces-j/treeview.html)
output result on my out0.html, it shows as a wrong tree structure. It is
not what we want. It thinks <html> has only one child, like <meta>, but
not <head> and <body>. The DOMTree.java in TreeViewer package also use 
NodeList to walk through the nodes in jtidy.

Anyway, is there any other way to walk through all the nodes generated by
JTidy other than using NodeList? Because i do think "NodeList" is a
"list", but not tree. I do care that maybe all the node(s) generated by
Tidy.parseDOM() are in a list structure, but not a tree. If this is true,
i think that i cannot get the correct html tree nodes as you said. What i
want is exactly what is in your email: "head and body elements are
children of the html element".

It is really urgent for me to wait for your reply. I really appreciate it.

Regards,

Major 


On Mon, 8 Jan 2001, Gary L Peskin wrote:

> Chunbo Shao wrote:
> > 
> > Dear Sir,
> > 
> > Great thanks for your kind help.
> > 
> > When i use TestDom.java, I find the number of the child generated by it is
> > not correct in html tree. The actual code is
> >          NodeList children = node.getChildNodes();
> >          if ( children != null ) {
> >             int len = children.getLength();
> >             for ( int i = 0; i < len; i++ ) {
> >                print(children.item(i));
> > 
> > Here, it seems that "len" is the number of children, but it is not
> > correct. Is this problem solved? how?
> 
> Major --
> 
> This code works fine for me.  How are you setting the variable "node"? 
> In my tests, getLength() seems to return the correct value.  Remember
> that the html element is the child of the document node and that the
> head and body elements are children of the html element.
> 
> If you're unable to figure out what the problem is, please forward your
> complete java code, the html page you're using, and the output that
> you're receiving along with a note indicating where you think that the
> output is wrong.
> 
> Gary
> 
> 


Received on Monday, 8 January 2001 15:13:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:45 GMT