我正在用java編寫一個應用程序,使用import org.jdom。*;如何從JDOM獲取節點內容
我的XML是有效的,但有時它包含HTML標籤。例如,像這樣:
<program-title>Anatomy & Physiology</program-title>
<overview>
<content>
For more info click <a href="page.html">here</a>
<p>Learn more about the human body. Choose from a variety of Physiology (A&P) designed for complementary therapies.&#160; Online studies options are available.</p>
</content>
</overview>
<key-information>
<category>Health & Human Services</category>
所以我的問題是與< P>在overview.content節點內的標籤。
我希望這個代碼將工作:
Element overview = sds.getChild("overview");
Element content = overview.getChild("content");
System.out.println(content.getText());
但它返回空白。
如何從overview.content節點返回所有文本(嵌套標籤和全部)?
感謝
嗨,我怎麼能拉平內容節點進行遞歸,當文本與其他節點的混合。例如,超鏈接位於句子的中間。我已經添加了一些幫助。 –
需要獲取內容標記中的所有HTML,包括鏈接和有序列表。謝謝 –