1

I'm using Jsoup to parse xml, I have to grab links from an RSS feed such as this http://feeds.guardian.co.uk/theguardian/rss , I just need advise on how to go about this in Java, I know how to parse a single line , but how would I go about grabbing all the links?

user2352335
  • 19
  • 1
  • 2

1 Answers1

2

You can select links with the Jsoup selector api (see here).

In most cases your code will look something like this:

Document doc = Jsoup.connect(url).get(); // connect to url and parse its conntent into a document

Elements elements = doc.select("your selector string"); // select your elements from the document


for( Element element : elements ) // iterate over each elements you've selected
{
    // do something
}

See also:

Community
  • 1
  • 1
ollo
  • 24,797
  • 14
  • 106
  • 155