Java Reference
In-Depth Information
The method uses an
XmlSlurper
to convert the XML box score into a DOM tree, ex-
tracts the needed information, and creates and returns an instance of the
Game-Result
class.
There's one other method in the
GetGameData
class, which is the one used to parse the
web page listing the games for that day. This is necessary because due to rain-outs and
other postponements there's no way to know ahead of time which games will actually be
played on a given day.
Parsing HTML is always a dicey proposition, especially because it may not be well-
It also demonstrates regular-expression mapping in Groovy. The
getGames
method from
GetGameData
is shown in the next listing.
10
See, for example, the NekoHTML parser at
http://nekohtml.sourceforge.net/
.