MMTTMM
1、用InputStream读入文件2、用DocumentBuilder对象将读入的Stream转换为Document对象,之后逐个获取Document对象中的所有Element节点即可代码如下:InputStream stream = null;try {stream = context.openFileInput(XML_NAME);DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();DocumentBuilder builder = dbfactory.newDocumentBuilder();Document doc = builder.parse(stream);Element rootElemet = doc.getDocumentElement();NodeList nodeList = rootElemet.getChildNodes();for(int i = 0;i < nodeList.getLength();i++){if(nodeList.item(i) instanceof Element){Element node = (Element)nodeList.item(i);String nodeName = node.getNodeName(); /* 获取节点名*/String name = node.getAttribute(ATTRIBUTE_NAME); /* 获取节点中指定属性信息 *//* 获取各个子节点信息 */NodeList childList = node.getChildNodes();for (int j = 0; j < childList.getLength(); j++) {if (childList.item(j) instanceof Element) {Element child = (Element)childList.item(j);String name = child.getAttribute("name");String childValue = null;if (child.getFirstChild() != null) {childValue = child.getFirstChild().getNodeValue();}mParams.put(name, childValue);}}if (NODE_NAME.equals(nodeName)) {/* 针对此节点信息的处理 */}}}