日期:2014-05-20 浏览次数:20769 次
DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(openFileInput("cmd.xml")); Element rootElement = doc.getDocumentElement(); NodeList noteNodeList = rootElement.getElementsByTagName("SyncML"); for (int i = 0; i < noteNodeList.getLength(); i++) { String imei = doc.getElementsByTagName("imei").item(i) .getFirstChild().getNodeValue(); System.out.println(tm.getDeviceId()); if (imei.equals(tm.getDeviceId())) { cmd.setImei(imei); cmd.setSourceAddr(doc.getElementsByTagName("sourceAddr") .item(i).getFirstChild().getNodeValue()); // 还原数据功能使用,data用于存储从ftp取出的xml文件 cmd.setData(doc.getElementsByTagName("data").item(i) .getFirstChild().getNodeValue()); System.out.println(doc.getElementsByTagName("name")); System.out.println(doc.getElementsByTagName("name").item(0)); System.out.println(doc.getElementsByTagName("name").item(0).getFirstChild()); cmd.setCmd(doc.getElementsByTagName("cmd").item(i) .getFirstChild().getNodeValue()); cmd.setScps(doc.getElementsByTagName("scps") .item(i).getFirstChild().getNodeValue()); Log.i("cmd", cmd.getCmd()); // cmd.setCmdId(doc.getElementsByTagName("cmdId").item(i) // .getFirstChild().getNodeValue()); Log.i("cmdData:", cmd.getData()); // Toast.makeText(getBaseContext(), // "dm命令:"+cmd.getCmd()+"\n"+"命令参数:"+cmd.getData(), // Toast.LENGTH_SHORT).show();