Stephen Cunningham
Stephen Cunningham

Reputation: 109

This element neither has attached source nor attached Javadoc and hence no Javadoc could be found

I am having this problem using Jsoup in Eclipse. I have attached the following jar files: jsoup 1.7.2.jar jsoup 1.7.2.javadoc.jar jsoup 1.7.2.sources.jar I have added these jar files as external jar files in the configuration path and have linked them to the C:\USERS drive where I stored the files. The program has no errors but when I run it I get the NullPointerException error on this line "Element gameElement = firstLottoRow.child(1);" or any other line of code like this that is using Jsoup to parse HTML from the URL. I am getting the "element neither has attached source nor attached Javadoc and hence no Javadoc could be found" with the line of code: "Element tbody = table.getElementsByTag("tbody").first();"

Am I doing everything right in terms of my configuration path linking to the jsoup jar files, or could anyone please suggest what I am doing wrong? Thanks so much for any help!

Here is the Jsoup code:

private LotteryDraw extractLotteryDraw(String html) {


        LotteryDraw lotteryDraw = new LotteryDraw();

        Document doc = Jsoup.parse(html);

        Elements elements = doc.getElementsByClass("drawhistory");
        //System.out.println(elements.toString());
        Element table = elements.first();
        Element tbody = table.getElementsByTag("tbody").first();
        Element firstLottoRow = tbody.getElementsByClass("lottorow").first();

        Element dateElement = firstLottoRow.child(0);
        System.out.println(dateElement.text());

        Element gameElement = firstLottoRow.child(1);
        System.out.println(gameElement.text());

        Element noElement = firstLottoRow.child(2);
        System.out.println(noElement.text());
        String[] split = noElement.text().split(" - ");

        int[] numbers = new int[split.length];

        int i = 0;
        for (String strNo : split) {
            numbers[i] = Integer.valueOf(strNo);
            i++;
        }

        lotteryDraw.setNumbers(numbers);
        Log.v("DEBUG", "the value of numbers is " + numbers);
        Element bonusElement = firstLottoRow.child(3);
        Integer bonusBall = Integer.valueOf(bonusElement.text());

        lotteryDraw.setBonusBall(bonusBall);
        Log.v("DEBUG", "the value of numbers is " + numbers);
        return lotteryDraw;

Upvotes: 1

Views: 10089

Answers (1)

Henry
Henry

Reputation: 43778

Instead of adding the src and javadoc jar files as external jar attach them to the jar with the classes as source or javadoc attachment.

Right click on the library jar and select "Properties". In the dialog that opens specify the location of the source and/or javadoc jar.

Upvotes: 3

Related Questions