Java Reference
In-Depth Information
/**
* This method looks for a link tag at the specified URL. If
* a link tag is found that specifies an RSS feed, then
* that feed is displayed.
* @param url The URL of the web site.
* @throws IOException Thrown if an IO exception occurs.
* @throws SAXException Thrown if an XML parse exception occurs.
* @throws ParserConfigurationException Thrown if there is
* an error setting
* up the parser.
*/
public void process(URL url)
throws IOException, SAXException,
ParserConfigurationException
{
String href = null;
InputStream is = url.openStream();
ParseHTML parse = new ParseHTML(is);
int ch;
do
{
ch = parse.read();
if (ch == 0)
{
HTMLTag tag = parse.getTag();
if (tag.getName().equalsIgnoreCase("link"))
{
String type = tag.getAttributeValue("type");
if (type != null && type.indexOf("rss") != -1)
{
href = tag.getAttributeValue("href");
}
}
}
} while (ch != -1);
if (href == null)
{
System.out.println("No RSS link found.");
} else
processRSS(new URL(href));
}
Search WWH ::




Custom Search