Android examples for XML:XML Node
Get Node List from XML File
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /**/*from w ww.ja va 2 s. com*/ * * @param in_Tag * String * @param in_FileName * String * @throws Exception * @return NodeList */ public static NodeList GetNodeList(String in_Tag, String in_FileName) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(in_FileName); Element root = doc.getDocumentElement(); return root.getElementsByTagName(in_Tag); } }