简体   繁体   English

卡在Jsoup解析HTML中

[英]Stuck in Jsoup parsing Html

how can i get that textA, text B and text C seperately? 我怎样才能分别获得textA,B和C?

i have tried .Owntext buth it gives all of them.I need something that gives text between two unique named h3s. 我已经尝试过.Owntext buth它可以提供所有这些。我需要一些东西可以在两个唯一的命名h3s之间提供文本。

  <div class="Example">
      <h3>A:</h3>
       TextA
      <h3>B:</h3>
       TextB
      <h3>C:</h3>
       TextC
  <\div>

This is almost a perfect answer for your question. 几乎是您问题的完美答案。 It would look about like this: 它看起来像这样:

Document doc = Jsoup.parse(str);
Element div = doc.select("div").first();

for (Node node : div.childNodes()) {
    if (node instanceof org.jsoup.nodes.TextNode) {
        System.out.println(node.toString();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM