0
我正在嘗試解析xml格式的html響應。xml文檔生成器給出錯誤
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream in = new FileInputStream(htmlresponse);
InputSource inputSource = new InputSource(new InputStreamReader(in));
Document xmlDocument = builder.parse(inputSource); //Error is here
但是,我收到了一條關於我已經評論過的錯誤。
Error - "the method parse(InputStream) in the type DocumentBuilder is not applicable for the arguments (InputSource)"
「DocumentBuilder類型中的方法解析(InputStream)不適用於參數(InputSource)」 – Harshit
方法parse()可以將InputSource或InputStream作爲Java7中的參數http://docs.oracle.com /javase/7/docs/api/javax/xml/parsers/DocumentBuilder.html。您使用的是哪個版本的Java? – Jay
1.6.0_27。同時在eclipse中,當我指出可能的解決方案的錯誤時,它說「重命名文件」 – Harshit