I'm trying to parse the bunch of xml files from a folder and return all the tags that contain particular expression. Below is what I did,
public class MyDomParser {
public static void main(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
File folder = new File("C:\\Users\\xmlfolder");
DocumentBuilder builder = factory.newDocumentBuilder();
for(File workfile : folder.listFiles()){
if(workfile.isFile()){
Document doc = builder.parse(workfile);
}
}
}
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
How do I loop through all the tags in each XML and return the tags that contain the expression "/server[^<]*".
Any help is much appreciated.