I am having difficulty effectively parsing XML that I’ve retrieved from Major League Baseball (MLB).
First of all, this is a side project intended for me to gain familiarity with XML. I am most familiar with R so I feel I stand a better chance debugging code once I am successful.
I am able to acquire the xml via these lines of code:
xmlurl<-"http://gd2.mlb.com/components/game/mlb/year_2012/month_06/day_11/miniscoreboard.xml"
xmltree<-xmlTreeParse(xmlurl,useInternalNodes=TRUE)
I would love to be able to extract information throughout the XML. For example, for all games played on this day, I would like to extract the number of runs scored by each team (“away_team_runs” & “home_team_runs”). Furthermore, I would like to be able to basically extract anything from the document that I wished yet I am unsuccessful in doing so, so far.
Any pointers would be greatly appreciated.
e.g , Using xpathSApply