← Prev in month
← Prev in thread
Next in thread →
Next in month →
DOM traversal: NodeIterator + NodeFilter vs. TreeWalker
Hi,
It seems to me that TreeWalker can very easily be simulated using
NodeIterator with a Nodefilter. In Java my filter could look like this:
class CustomFilter implements NodeFilter
{
public short acceptNode(Node node)
{
…
}
}
Since the member function acceptNode() takes a node as its input that
means that in this function I have access to all member functions of the
Node object:
|*getFirstChild <cid:>*()
*getLastChild <cid:>*()
*getNextSibling <cid:>*||()
*getParentNode <cid:>*||()|
| a.s.o.|
| Using those functions I can fully access the DOM tree even if the
object implementing NodeIterator is not aware of the tree-like structure
of DOM. Isn’t this the “r|eason d'être”| for the TreeWalker interface ?
(the fact that NodeIterator uses a ‘flat’ model for its DOM
representation)||
Are there situation where a TreeWalker is more appropriate than a
NodeIterator + NodeFilter ? Please provide an example.|
|
Regards,
Razvan|
|www.mihaiu.name <http://www.mihaiu.name/>
|
|
|
← Prev in month
← Prev in thread
Next in thread →
Next in month →