CustomNodeFilter can be used to define your own NodeFilter for use
with NodeIterators and TreeWalkers. You can create a custom filter
by doing the following:
class MyCustomNodeFilter {
.....
virtual short acceptNode (const Node &n);
.....
}
Then in your program:
short MyCustomNodeFilter.acceptNode (const Node &n)
{
if (condition)
return NodeFilter.FILTER_ACCEPT;
else
....
}
MyCustomFilter *filter = new MyCustomFilter();
NodeFilter nf = NodeFilter.createCustom(filter);
NodeIterator ni = document.createNodeIterator(document,NodeFilter.SHOW_ALL,nf,false);
The default implementation of acceptNode() returns NodeFilter.FILTER_ACCEPT
for all nodes.
|