bakDiagramFile(filename,saName);/
SAXBuilder sb = new SAXBuilder();
try {
Document doc = sb.build(filename );/filename是要解析的xml文件
Element root = doc.getRootElement();
List componentFlowEditorElements = root.getChildren();
for (int i = 0; i < componentFlowEditorElements.size(); i++) {
Element element = (Element) componentFlowEditorElements.get(i);
if ("children".equals(element.getName()) || "edges".equals(element.getName())) {
List children = element.getChildren();
for(int j=0;j<children.size();j++){
Element childrenElement =(Element) children.get(j);
if ("children".equals(childrenElement.getName())){
childrenElement.removeChild("element");
}
}
}
}
XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat().setEncoding("ASCII"));
File file2 = new File(filename);
FileWriter writer = new FileWriter(file2);
xmlOut.output(doc, writer);
writer.close();
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}