Created
December 6, 2010 21:29
-
-
Save joesavak/730985 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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