private void parseXMLFile(File existingFile, String beanName, String tokenToReplace, String fileVariable) {
String nameInComment = beanName;
if (beanName == null) {
nameInComment = pojoName;
}
Replace replace1 = (Replace) antProject.createTask("replace");
replace1.setFile(existingFile);
replace1.setToken("<!--" + nameInComment + "-START-->");
replace1.setValue("REGULAR-START");
replace1.execute();
Replace replace2 = (Replace) antProject.createTask("replace");
replace2.setFile(existingFile);
replace2.setToken("<!--" + nameInComment + "-END-->");
replace2.setValue("REGULAR-END");
replace2.execute();
ReplaceRegExp regExpTask = (ReplaceRegExp) antProject.createTask("replaceregexp");
regExpTask.setFile(existingFile);
regExpTask.setMatch("REGULAR-START(?s:.)*REGULAR-END");
regExpTask.setReplace("");
regExpTask.setFlags("g");
regExpTask.execute();
Replace replaceData = (Replace) antProject.createTask("replace");
replaceData.setFile(existingFile);
replaceData.setToken(tokenToReplace);
String stringWithProperLineEndings = adjustLineEndingsForOS(antProject.getProperty(fileVariable));
replaceData.setValue(stringWithProperLineEndings);
replaceData.execute();
}