Java Reference
In-Depth Information
The key-value pairs in the
abbrevs
map hold the three-letter abbreviations for each team
and the city name, respectively.
Thenextstepistoprocesstheactualboxscores.Here'ssomesampledata,takenatrandom.
in XML form, truncated to show the typical elements without showing them all.
9
Just happens to be the day the Red Sox won the World Series in 2007.
Listing 2.6. boxscore.xml: the box score from game 4 of the 2007 World Series
<boxscore game_id=
"2007/10/28/bosmlb-colmlb-1"
game_pk=
"224026"
home_sport_code=
"mlb"
away_team_code=
"bos"
home_team_code=
"col"
away_id=
"111"
home_id=
"115"
away_fname=
"Boston Red Sox"
home_fname=
"Colorado Rockies"
away_sname=
"Boston"
home_sname=
"Colorado"
date=
"October 28, 2007"
away_wins=
"5"
away_loss=
"0"
home_wins=
"0"
home_loss=
"5"
status_ind=
"F"
>
<linescore away_team_runs=
"4"
home_team_runs=
"3"
away_team_hits=
"9"
home_team_hits=
"7"
away_team_errors=
"0"
home_team_errors=
"0"
>
<inning_line_score away=
"1"
home=
"0"
inning=
"1"
/>
<inning_line_score away=
"0"
home=
"0"
inning=
"2"
/>
...
<inning_line_score away=
"0"
home=
"0"
inning=
"9"
/>
</linescore>
<pitching team_flag=
"away"
out=
"27"
h=
"7"
r=
"3"
er=
"3"
bb=
"3"
so=
"7"
hr=
"2"
bf=
"37"
era=
"2.60"
>
<pitcher id=
"452657"
name=
"Lester"
pos=
"P"
out=
"17"
bf=
"23"
er=
"0"
r=
"0"
h=
"3"
so=
"3"
hr=
"0"
bb=
"3"
w=
"2"
l=
"0"
era=
"0.00"
note=
"(W, 2-0)"
/>
<pitcher id=
"434668"
name=
"Delcarmen"
pos=
"P"
out=
"2"
bf=
"4"
er=
"1"
r=
"1"
h=
"2"
so=
"1"
hr=
"1"
bb=
"0"
w=
"0"
l=
"0"
era=
"9.00"
note=
"(H, 2)"
/>
...
<pitcher id=
"449097"
name=
"Papelbon"
pos=
"P"
out=
"5"
bf=
"5"
er=
"0"
r=
"0"
h=
"0"
so=
"1"
hr=
"0"
bb=
"0"
w=
"0"
l=
"0"
era=
"0.00"
note=
"(S, 4)"
/>
</pitching>
<batting team_flag=
"home"
ab=
"34"
r=
"3"
h=
"7"
d=
"2"
t=
"0"
hr=
"2"
rbi=
"3"
bb=
"3"
po=
"27"
da=
"18"
so=
"7"
avg=
".216"
lob=
"12"
>
<batter id=
"430565"
name=
"Matsui"
pos=
"2B"
bo=
"100"
ab=
"4"
po=
"3"
r=
"0"
bb=
"0"
a=
"5"
t=
"0"
sf=
"0"
h=
"1"
e=
"0"
d=
"1"
hbp=
"0"
so=
"1"
hr=
"0"
rbi=
"0"
lob=
"2"
fldg=
"1.000"
avg=
".286"
/>
<batter id=
"466918"
name=
"Corpas"
pos=
"P"
bo=
"101"
ab=
"0"
po=
"0"
r=
"0"
bb=
"0"
a=
"1"
t=
"0"
sf=
"0"
h=
"0"
e=
"0"
d=
"0"
hbp=
"0"
so=
"0"
hr=
"0"
rbi=
"0"
lob=
"0"
fldg=
"1.000"
avg=
".000"
/>
...
</batting>