Skip to content

Instantly share code, notes, and snippets.

Embed
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;
}
};
parser.parse(input);
in.close();
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