日期:2014-05-16 浏览次数:20583 次
public static void main(String[] args) {
Document documentObjective = load(path);// 获取xml文件对象
Element listNodes = documentObjective.getRootElement();
List<Map<String, String>> permissions = new ArrayList<Map<String, String>>();
Map<String, String> map1 = new HashMap<String, String>();
map1.put("permission", "android.permission.INTERNET");
permissions.add(map1);
Map<String, String> map2 = new HashMap<String, String>();
map2.put("permission", "android.permission.RECEIVE_SMS");
permissions.add(map2);
Map<String, String> map3 = new HashMap<String, String>();
map3.put("permission", "android.permission.RECORD_AUDIO");
permissions.add(map3);
if (null != permissions && permissions.size() > 0) {
for (Map<String, String> map : permissions) {
String nodeXml = map.get("permission");// 添加到目标文件的内容
listNodes.addElement("uses-permission").addAttribute("android:name", nodeXml);// 添加到目标文件
}
outputxml(documentObjective, path);
}
}