Java Reference
In-Depth Information
/**
* Process the specified URL and extract the option list there.
* @param url The URL to process.
* @param optionList Which option list to process, zero
* for first.
* @throws IOException Any exceptions that might have
* occurred while reading.
*/
public void process(URL url, int optionList) throws IOException
{
String value = "";
InputStream is = url.openStream();
ParseHTML parse = new ParseHTML(is);
StringBuilder buffer = new StringBuilder();
advance(parse, "select", optionList);
int ch;
while ((ch = parse.read()) != -1)
{
if (ch == 0)
{
HTMLTag tag = parse.getTag();
if (tag.getName().equalsIgnoreCase("option"))
{
value = tag.getAttributeValue("value");
buffer.setLength(0);
} else if (tag.getName().equalsIgnoreCase("/option"))
{
processOption(buffer.toString(), value);
} else if (tag.getName().equalsIgnoreCase("/choice"))
{
break;
}
} else
{
buffer.append((char) ch);
}
}
}
Search WWH ::




Custom Search