System.out.println(c);
}
System.out.println();
System.out.println("Only elements:");
itr = doc.getDescendants(new ElementFilter());
while (itr.hasNext()) {
Content c = (Content) itr.next();
System.out.println(c);
}
System.out.println();
System.out.println("Everything that's not an element:");
itr = doc.getDescendants(new ElementFilter().negate());
while (itr.hasNext()) {
Content c = (Content) itr.next();
System.out.println(c);
}
System.out.println();
System.out.println("Only elements with localname of servlet:");
itr = doc.getDescendants(new ElementFilter("servlet"));
while (itr.hasNext()) {
Content c = (Content) itr.next();
System.out.println(c);
}
System.out.println();
System.out.println(
"Only elements with localname of servlet-name or servlet-class:");
itr = doc.getDescendants(new ElementFilter("servlet-name")
.or(new ElementFilter("servlet-class")));
while (itr.hasNext()) {
Content c = (Content) itr.next();
System.out.println(c);
}
System.out.println();
System.out.println("Remove elements with localname of servlet:");
itr = doc.getDescendants(new ElementFilter("servlet"));
while (itr.hasNext()) {
itr.next();
itr.remove();
}