DJ原生摇摆jwebbrowser html解析错误

时间:2013-12-17 14:44:39

标签: java html-parsing jwebbrowser djnativeswing

我有一个错误htmlparsing。 我认为问题源于引号DjNative语言= javascript error language =“javascript”我尝试所有版本的Dj本机库

[致命错误]:2:18:对于与元素类型“language”相关联的属性“{1}”,需要打开引号。 org.xml.sax.SAXParseException; lineNumber:2; columnNumber:18;对于与元素类型“language”相关联的属性“{1}”,需要打开引号。     at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)     at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)

  private Document HTMLtoXML(String source)
 {
 Document doc = null;
     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     DocumentBuilder builder;
     try {
         builder = factory.newDocumentBuilder();
         InputSource src = new InputSource(new StringReader(source));
         doc = builder.parse(src);
     } catch (ParserConfigurationException e) {
         e.printStackTrace();
     } catch (SAXException e) {
        e.printStackTrace();
     } catch (IOException e) {
        e.printStackTrace();
     }
 return doc;  
 }

 public void StartTakip()
{   
  String htmlSource=webbrowser.getHTMLContent();
  dc = HTMLtoXML(htmlSource);   

 }

当我尝试通过DJNative Swing获取页面源代码为html页面时

<HTML>
<HEAD>
<SCRIPT language=javascript src="/medula/scripts/capFirstLetters.js"></SCRIPT>
<TITLE>deneme</TITLE>
</HEAD>
<BODY bgcolor=#233333>
</BODY>
</HTML>

如果来源如下,html解析工作正常

<HTML>
<HEAD>
<SCRIPT language="javascript" src="/medula/scripts/capFirstLetters.js"></SCRIPT>
<TITLE>deneme</TITLE>
</HEAD>
<BODY bgcolor="#233333">
</BODY>
</HTML> 

1 个答案:

答案 0 :(得分:0)

我用Jsoup-1.7.3.jar解决了这个问题   例如:

  JWebBrowser jwebbrowser=new Jwebbrowser();
  Document doc=Jsoup.parse(jwebbrowser.getHTMLContent);