针对于类似资源文件的主题style的name一样,但style下的item的name有不同的
public class Style {
public static void main(String[] args) throws DocumentException, IOException {
File filesCompare = new File("/Users/jiajia/Desktop/wire-ui");
File files = new File("/Users/jiajia/Desktop/base");
File[] listFiles = files.listFiles();
for (File childListFile : listFiles) {//res文件下的所有文
SAXReader reader = new SAXReader();
Document document = reader.read(childListFile.getAbsolutePath());
Element rootElement = document.getRootElement();//获取文件的根结点
//System.out.println(rootElement.getName());
//对某节点下的所有子节点进行遍历.
for (Iterator it = rootElement.elementIterator(); it.hasNext(); ) {
Element element = (Element) it.next();
Attribute attribute = element.attribute("name");//获取子节点属性"name"
for (File childListFileCompare : filesCompare.listFiles()) {//res文件下的所有文件
SAXReader readerCompare = new SAXReader();
Document documentCompare = readerCompare.read(childListFileCompare.getAbsolutePath());
Element rootElementCompare = documentCompare.getRootElement();//获取文件的根结点
//对某节点下的所有子节点进行遍历.
for (Iterator itCompare = rootElementCompare.elementIterator(); itCompare.hasNext(); ) {
Element elementCompare = (Element) itCompare.next();
Attribute attributeCompare = elementCompare.attribute("name");//获取子节点属性"name"
if (element.getName().equals(elementCompare.getName()) && attribute.getValue().equals(attributeCompare.getValue())) {
List<Element> elementBase = element.elements();
List<Element> elementWireUi = elementCompare.elements();
if (elementBase.size() != elementWireUi.size()) {
List<String> wireUiName = new ArrayList<>();
for (int j =0;j < elementWireUi.size();j ++){
wireUiName.add(elementWireUi.get(j).attribute("name").getValue());
}
for (int i= 0; i< elementBase.size(); i ++){
if (!(wireUiName.contains(elementBase.get(i).attribute("name").getValue()))){
System.out.println("DELTE_ELEMENT" + childListFile.getAbsolutePath());
System.out.println("DELTE_ELEMENT" + element.getName());
System.out.println("DELTE_ELEMENT" + attribute.getName() + "==" + attribute.getValue());
System.out.println("DELTE_ELEMENT" + elementBase.get(i).attribute("name").getName() + "==" + elementBase.get(i).attribute("name").getValue());
}
}
}
}
}
}
}
}
}
}