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>
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号