Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7183843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:04:43+00:00 2026-05-28T18:04:43+00:00

Recently started programming Android Java (Eclipse), Im trying to make a simple reader app

  • 0

Recently started programming Android Java (Eclipse), Im trying to make a simple reader app using jsoup.

Ive got html like this;

<article id="id" class="artikel">
<h1>Title</h1>
<p>paragraph 1</p>
<p>paragraph 2</p>
<p>paragraph 3</p>
</article>

<article id="id">
<p>comment1</p>
</article>

<article id="id">
<p>comment2</p>
</article>

Amounts of paragraphs is variable. The amount of comments as well.
I want to get all the paragraphs within the article, none of the comments.
The real article is always the first article tag, so Im using first() in combination with a wildcard to get it.

Here is the method Im using;

public String GetArticleBody(Document adoc)
{
    //Document totalbody = (Document)adoc.select("article *").first();
    //Element totalbody = adoc.select("article *").first();
    //Elements paragraphs = adoc.select("article * > p);
    Elements paragraphs = adoc.select(".article* p");
    String body = "test";
    for (Element p : paragraphs)
    {
        body = StringAttacher(body, p.text());
    }
    System.out.println(body);
    return body;
}

As you can see Ive been fooling around with the methods from the cookbook and a few I found on SOF.
From all of these methods all Ive ever gotten back is just the word test or nothing at all.

Could someone point me in the right direction to get those paragraphs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:04:44+00:00Added an answer on May 28, 2026 at 6:04 pm

    The issue you have is using the wrong selector in your first statement.

    . is the “class” selector, so you either hav “article” speller wrong, or have a . when you shouldn’t.

    Try this instead:

    public String GetArticleBody(Document adoc)
    {
        //Document totalbody = (Document)adoc.select("article *").first();
        //Element totalbody = adoc.select("article *").first();
        //Elements paragraphs = adoc.select("article * > p);
        Elements paragraphs = adoc.select("article").first().select("p");
        String body = "test";
        for (Element p : paragraphs)
        {
            body = StringAttacher(body, p.text());
        }
        System.out.println(body);
        return body;
    }
    

    This will get you the paragraphs in the first article.

    Also, it often helps to remember that the jsoup selectors are the same as the ones used in CSS selectors (and a sub-set of the jQuery selectors). Any knowledge you have from those other areas is directly useable with jsoup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently started programming for Android using the Eclipse ADT. What I am frequently
I recently started using Eclipse at work for my Java servlet projects. I've been
I've started Android programming recently so bear with me :) I develop an app
I just recently started with object oriented programming, using java. Before I was programming
I recently started programming for android and java development in general. Currently I train
We recently started using maven for dependency management. Our team uses eclipse as it's
I recently started programming in WinForms using C#. I have a requirement where I
I recently started programming my first Cocoa app. I have ran into a problem
I recently started game programming on the iPhone using Cocos2d and Box2d. So here's
I recently started backend programming with Java servlets to access data for intranet webapps.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.