0
我試圖把關閉標籤的關閉自動生成和我提到了這個鏈接關閉自動關閉標籤在jsoup
How to turn off automatic generation of close tags </tagName> in Jsoup?
String html="<A HREF=\"#Item1\">\n"
+ "<p style=\"font-family:times;margin-top:12pt;margin-left:0pt;\">\n"
+ "<FONT SIZE=2>Item 1.</FONT>\n"
+ "</A>";
Document document = Jsoup.parse(html,"",Parser.xmlParser());
但是當我嘗試,我沒有得到任何輸出和我認爲它會進入一個不確定的循環或其他東西。
這是我正努力代碼:(沒有輸出和掛)
String html = "<table>"
+ "<tr align='top'>"
+ "<th><font>Link</th>"
+ "</tr>"
+ "</table>";
Document document = Jsoup.parse(html,"",Parser.xmlParser());
System.out.println(document.toString());
誰能告訴我是什麼錯誤? 我需要的是某種輸出說終端標籤丟失。
編輯 - 對不起有一些問題,我eclipse.Anyway現在沒有無限循環,但我的輸出如下
String html = "<table>"
+ "<tr align='top'>"
+ "<th><font>Link</th>"
+ "</tr>"
+ "</table>";
Document document = Jsoup.parse(html,"",Parser.xmlParser());
System.out.println("UNPARSED = \n"+html + "\n---------------");
System.out.println("parsed:" + document.toString());
輸出
UNPARSED =
<table><tr align='top'><th><font>Link</th></tr></table>
---------------
parsed:<table>
<tr align="top">
<th><font>Link</font></th>
</tr>
</table>
我不想讓</font>
待加入。
編輯 -
我通過Jsoup解析之前,使用正則表達式檢查固定它。
我想在所有開始和結束標記之間做一個匹配,看看它是否正確匹配。 – Abi
你能舉個例子嗎? – chengpohi
在我的示例中,沒有結束標記。我希望這一點被指出。 – Abi