0

Why can I not get the text from this element?

Elements el = doc.select("#Core_UI_AutogeneratedID_0 > fieldset:nth-child(1) > p:nth-child(23)");
for (Element e : el) {
      System.out.println(e.text());
}

I am connecting to the website fine, it's this line that's the issue

Elements el = doc.select("#Core_UI_AutogeneratedID_0 > fieldset:nth-child(1) > p:nth-child(23)");

How would I print an Element?

HTML format:

<div class="Content">
<fieldset class="TableLike FixedLabelSmall Narrow">

    <label>Age:</label>
    <p class="Value" title="9 d 21 h ">9 d 21 h </p>
    <div class="Clear"></div>

    <label>Created:</label>
    <p class="Value" title="06/13/2015 11:10">06/13/2015 11:10</p>
    <div class="Clear"></div>


    <label>State:</label>
    <p class="Value" title="closed successful">closed successful</p>
    <div class="Clear"></div>

    <label>Locked:</label>
    <p class="Value" title="unlock">unlock</p>
    <div class="Clear"></div>

    <label>Priority:</label>
    <p class="Value" title="3 normal">3 normal</p>
    <div class="Clear"></div>

    <label>Queue:</label>
    <p class="Value" title="Sydney">Sydney </p>
    <div class="Clear"></div>

    <label>Service:</label>
    <p class="Value" title="SUV">SUV</p>
    <div class="Clear"></div>
    <label>Service Level Agreement:</label>
    <p class="Value" title="**I WANT THIS TEXT**">Sydney SLA</p>
    <div class="Clear"></div>

</fieldset>
5
  • what is the html structure of this part that you are trying to select ?? Jun 23, 2015 at 1:57
  • that's fine but can you give the link of the page or the entire source code .post entire HTML structure somewhere like pastebin.com then add link to your question because can't see Core_UI_AutogeneratedID_0 Jun 23, 2015 at 2:44
  • I cannot show you the whole website as it is a private website but could you show me with this website en.wikipedia.org/wiki/Sample_(statistics) with this element #toc > ul > li.toclevel-1.tocsection-2 > a > span.toctext to extract this text 2 Mathematical description of random sample
    – Ross
    Jun 23, 2015 at 2:57
  • with your given example page wiki your selectors are fine and it will get the text "Mathematical description of random sample" .didn't you able to get it using jsoup ??and try this site this will help to find is your selectors are ok for ur private website. try.jsoup.org Jun 23, 2015 at 3:10
  • That site is very good thanks
    – Ross
    Jun 23, 2015 at 3:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.