DOM based TagStripper
import org.apache.xerces.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import java.io.*;
public class DOMTagStripper extends NodeIterator {
public static void main(String[] args) {
DOMParser parser = new DOMParser();
NodeIterator iterator = new DOMTagStripper();
for (int i = 0; i < args.length; i++) {
try {
// Read the entire document into memory
parser.parse(args[i]);
Document d = parser.getDocument();
iterator.followNode(d);
}
catch (SAXException e) {
System.err.println(e);
}
catch (IOException e) {
System.err.println(e);
}
}
} // end main
public void processNode(Node node) {
int type = node.getNodeType();
if (type == Node.TEXT_NODE) {
System.out.print(node.getNodeValue());
}
}
}