Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2010 21:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Reader in = new BufferedReader(new FileReader(fileName));
Input Source input = new InputSource(in);
DOMParser parser = new DOMParser();
int whatToShow = NodeFilter.SHOW_ALL;
NodeFilter filter = new NodeFilter() {
public short acceptNode(Node n) {
if (n.getNodeType() == Node.TEXT_NODE) {
if(((Text)n).getData().trim().length() == 0)
return NodeFilter.FILTER_REJECT;
return NodeFilter.FILTER_ACCEPT;
Document doc = parser.getDocument();
DocumentTraversal traversal = (DocumentTraversal)doc;
TreeWalker walker = traversal.createTreeWalker(doc, whatToShow, filter, false);
//now we have a tree we can recursively walk down to create the needed staging tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment