user2352335
user2352335

Reputation: 19

Xml parsing using Jsoup

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

Answers (1)

ollo
ollo

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

Related Questions