I want to remove html div
and table
tables tags and anything inside it(childs), what's the best way to do it ?
I tried traversing the document like this but it's not working, in Jsoup documentation it says that node.remove()
removes the element from the DOM and his children's:
doc.traverse(new NodeVisitor() {
@Override
public void head(Node node, int i) {
}
@Override
public void tail(Node node, int i) {
//Log.i(TAG,"node: "+node.nodeName());
if( node.nodeName().compareTo("table") == 0 ||
node.nodeName().compareTo("div") == 0 )
node.remove();
}
});
Document doc = Jsoup.parse(html);
doc.select("table *").remove();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With