相关疑难解决方法(0)

如何从JDOM获取节点内容

我正在使用import org.jdom在java中编写应用程序.*;

我的XML有效,但有时它包含HTML标记.例如,像这样:

  <program-title>Anatomy &amp; 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&amp;P) designed for complementary therapies.&amp;#160; Online studies options are available.</p>
       </content>
  </overview>
  <key-information>
     <category>Health &amp; Human Services</category>
Run Code Online (Sandbox Code Playgroud)

所以我的问题是overview.content节点内的<p>标签.

我希望这段代码可行:

        Element overview = sds.getChild("overview");
        Element content = overview.getChild("content");

        System.out.println(content.getText());
Run Code Online (Sandbox Code Playgroud)

但它返回空白.

如何从overview.content节点返回所有文本(嵌套标签和所有文本)?

谢谢

java xml jdom xml-parsing

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

java ×1

jdom ×1

xml ×1

xml-parsing ×1