document转换不成功啊。.parse哪里卡住了!!
[img=http://m615.mail.qq.com/cgi-bin/viewfile?f=395DFE0AF343B4DB9156F2BC66584D61B2D3ED0B18EA70EEBD1822A5EF1464AB0878437248BE274C5F40B501138CBF52BD039ECC80DD35A817FA67818DABF9218B611595B6ED1CE6DD2E96CCE20A3349678FBF3C7A6405B8&mailid=ZL1311-yyPlc35BX8R5SH8xLcxFb1b&sid=5g6o-PHO92zRECdp][/img]卡在哪里了 等了好久 没有报错
在线急等。。。。。。 --------------------编程问答-------------------- private Document getDocument(String htm) {//htm是htm文件的本地地址
InputSource in = null;
try {
in = new InputSource(new FileInputStream(new File(htm)));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
.newInstance();
builderFactory.setNamespaceAware(true);
builderFactory.setValidating(true);
DocumentBuilder builder;
Document doc = null;
try {
builder = builderFactory.newDocumentBuilder();
doc = builder.parse(in);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return doc;
} --------------------编程问答--------------------
private Document getDocument(String htm) {//htm是htm文件的本地地址--------------------编程问答-------------------- 一般来说,导错包了 --------------------编程问答-------------------- 哦,我懂了,原因是你的html不是标准的xhtml也就是说不是xml,不是xml当然报错 --------------------编程问答-------------------- 噢 这样子的吗 我去试试先
InputSource in = null;
try {
in = new InputSource(new FileInputStream(new File(htm)));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
.newInstance();
builderFactory.setNamespaceAware(true);
builderFactory.setValidating(true);
DocumentBuilder builder;
Document doc = null;
try {
builder = builderFactory.newDocumentBuilder();
doc = builder.parse(in);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return doc;
}
补充:Java , Java EE