Java Reference
In-Depth Information
/**
* The main method, create a new instance of the object and call
* process.
* @param args not used.
*/
public static void main(String args[])
{
try
{
URL u = new URL("http://www.httprecipes.com/1/6/form.php");
ParseChoiceList parse = new ParseChoiceList();
parse.process(u, 1);
} catch (Exception e)
{
e.printStackTrace();
}
}
}
If you examine the HTML source code that makes up the states choice list you will see
the following:
<select name="state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
...
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
In the next section you will see how to parse these <option> tags into a comma delin-
eated list of states and abbreviations.
Search WWH ::




Custom Search