Reputation: 19
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?
Upvotes: 1
Views: 4543
Reputation: 25340
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:
Upvotes: 2