DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(inputStream);
Element element = document.getDocumentElement();
NodeList dataNodes = ((Element)element.getElementsByTagName("Application").item(0)).getChildNodes();
for(int i = 0; i < dataNodes.getLength(); i++){
if("Version".equals(dataNodes.item(i).getNodeName())){
System.err.println("版本信息 : " + dataNodes.item(i).getFirstChild().getNodeValue());
}else if("ChkUpdate".equals(dataNodes.item(i).getNodeName())){
System.err.println("版本信息 : " + dataNodes.item(i).getFirstChild().getNodeValue());
}else if("DownLoad".equals(dataNodes.item(i).getNodeName())){
System.err.println("版本信息 : " + dataNodes.item(i).getFirstChild().getNodeValue());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Applications>
<Application>
<Version>1.7</Version>
<ChkUpdate>baidu.com</ChkUpdate>
<DownLoad>sohu.com</DownLoad>
</Application>
</Applications>
Nach dem Login kopieren