// input source or reader. Result is root node of created
// tree-like structure. Single cleaner instance may be safely used
// multiple times.
// TagNode node = cleaner.clean( new File("tests/accept.html"));
TagNode node = cleaner.clean( new File("tests/rallypoint.htm"));
Object[] myNodes;
myNodes = node.evaluateXPath( "//div[@id='content']//h1/text( )");
String[] data = Util.patternExtract( "([^(]+)"+Translator.get(Translator.LEVEL)+" (\\d+)", myNodes[0].toString(), 2);
String currentLocation = Translator.translate( data[0].trim());
int level = Integer.parseInt( data[1].trim());
System.out.printf( "currentLocation=%s, level=%d\n\n", currentLocation, level);
int numNode = 0;
Object[] domTroops = node.evaluateXPath( "//div[@id='content']//table");
for( Object t : domTroops) {
if( t instanceof TagNode) {
TagNode domTroop = (TagNode) t;
Object[] domTroopTypes = domTroop.evaluateXPath( ".//tbody[@class='units']/tr[position()=1]/td/img/@title");
Object[] domTroopQuantities = node.evaluateXPath( ".//tbody[@class='units']/tr[position()=2]/td/text()");
Object[] domLocations = node.evaluateXPath( "//div[@id='content']//table/thead/tr/td[2]/a/@href");
String codLocation = "<local>";
if( numNode > 0) { // Other villages