/**
* parse XML file
* @param inputStream
* @return
*/
public static Element parseXml(InputStream inputStream) {
try {
SAXReader reader = new SAXReader();
Document document = reader.read(inputStream);
Element root = document.getRootElement(); // parse XML root.
//如果是多root的xml, 就这样取
List rootList = document.getRootElements();
//然后遍历出来就ok啦。。
//取得 节点内容 请参看 Element
root.element("节点名称").getText();
//或者
root.elementText("节点名称");
return root;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* Http:: doGet()
* @param action
* @return html InputStream
* @throws IOException
*/
public static InputStream doGet(String action) throws IOException {
URL url = new URL(action);
URLConnection uc = url.openConnection();
InputStream is = uc.getInputStream();
return is;
}