Re: Traversing tree nodes

> I am having difficulty traversing the tree tidy.parse() generates. I want
to
> skip contents of some elements. I have used
> "content" and "next" variables of the Node object to traverse the tree.
But
> they haven't been very useful when skipping contents. Here is an example:

I suggest that you get the latest Java tidy with DOM interfaces.
The method names such as 'getChildNodes' make the relationships
more clear.  The Java tidy web page has an updated sample that uses
the DOM interfaces, as returned by parseDOM().

In the following HTML file (with missing end tags added) the embedded
table will be a child of one of the td elements:

<html>
<head>
</head>
<body>
<table>
<thead>
<tr><td>table 1 - header info.
</td></tr>
</thead>
<tfoot>
<tr><td>table 1 - footer info.
</td></tr>
</tfoot>
<tbody>
<tr><td>
<table><thead><tr><td></td></tr>
</thead><tfoot><tr><td></td></tr></tfoot><tbody><tr><td>Skip
this table</td></tr></tbody></table>
</td></tr>
<tr><td>Skip embedded table to this row.
</td></tr>
</tbody>
</table>
</body>
</html>


Andy Quick

Received on Wednesday, 6 October 1999 23:45:47 UTC