Using add_key
is optional here, but it removes the need to hang on to the "game" table.
library(magrittr)
XML2Obs("http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_04/gid_2011_04_04_minmlb_nyamlb_1/players.xml") %>%
add_key(parent = "game", recycle = "venue") %>%
add_key(parent = "game", recycle = "date") %>%
collapse_obs -> tabs
tabs[["game//team//player"]][1:5, c("first", "last", "venue", "date")]
## first last venue date
## [1,] "Jim" "Thome" "Yankee Stadium" "April 4, 2011"
## [2,] "Carl" "Pavano" "Yankee Stadium" "April 4, 2011"
## [3,] "Michael" "Cuddyer" "Yankee Stadium" "April 4, 2011"
## [4,] "Joe" "Nathan" "Yankee Stadium" "April 4, 2011"
## [5,] "Joe" "Mauer" "Yankee Stadium" "April 4, 2011"