Java Reference
In-Depth Information
If a value is not present, then just display the key , which is the name of the attribute.
The key will be enclosed in quotes.
if (value == null)
{
buffer.append("\"");
buffer.append(key);
buffer.append("\"");
If a value is present, then display the key followed by an equals sign, followed by the
value. The value will be enclosed in quotes.
} else
{
buffer.append(key);
buffer.append("=\"");
buffer.append(value);
buffer.append("\"");
}
Once all of the attributes have been displayed, a trailing greater-than is appended to the
StringBuilder object, to end the tag.
buffer.append(">");
return buffer.toString();
Once the loop completes, the StringBuilder object is converted to a String ,
by calling its toString method. This String is returned.
Recipes
This chapter includes seven recipes. These recipes demonstrate how to extract data from
a variety of different HTML page types. Specifically, you will see how to extract data from
each of the following:
• Extract data from a choice list
• Extract data from a HTML list
• Extract data from a table
• Extract data from hyperlinks
• Extract images from an HTML page
• Extract data from HTML sub-pages
• Extract data form HTML partial-pages
All of the recipes in this chapter will make use of the HTML parsing classes that were
described in the first part of this chapter. We will begin with the first recipe, which shows you
how to extract data from a choice list.
Search WWH ::




Custom Search