同样的程序,Jcreate正常,wsad 5 报错!
ReadXml.java 如下:
import java.io.IOException;
import java.io.PrintStream;
import java.util.Vector;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.lang.String;
public class ReadXml {
public static void main(String args[]){
DocumentBuilderFactory documentbuilderfactory;
DocumentBuilder documentbuilder;
Document document;
try {
documentbuilderfactory = DocumentBuilderFactory.newInstance();
documentbuilder = documentbuilderfactory.newDocumentBuilder();
document = documentbuilder.parse("temp.xml");
document.normalize();
NodeList nodelist = document.getElementsByTagName("项目");
for (int i = 0; i < nodelist.getLength(); i++) {
Element ele = (Element) nodelist.item(i);
System.out.println(ele.getElementsByTagName("项目ID").item(0).getFirstChild().getNodeValue());
System.out.println(ele.getElementsByTagName("本月数").item(0).getFirstChild().getNodeValue());
System.out.println(ele.getElementsByTagName("累计数").item(0).getFirstChild().getNodeValue());
}
}catch (ParserConfigurationException e) {
System.out.println("你的jdk包不是1.3");
}catch (IOException e) {
System.out.println(e);
}catch (SAXException e) {
System.out.println(e);
}
}
}
Jcreate :路径,jdk 1.3 + Apache Crimson 1.1.3 运行正常,出来结果
wsad 5 : 路径,D:\IBM\WebSphere Studio\eclipse\jre\lib\rt.jar +
Apache Crimson 1.1.3
报错信息如下:
java.net.MalformedURLException: unknown protocol: d
document = documentbuilder.parse("temp.xml"); ====>>>>此行报错
请高手帮忙呀