Created
January 14, 2014 03:21
-
-
Save cpsievert/8412484 to your computer and use it in GitHub Desktop.
pbp_all.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#template for fixing bad xml files from nba.com | |
library(XML) | |
con <- url("http://www.nba.com/games/game_component/dynamic/20130528/MIAIND/pbp_all.xml") | |
corrupt <- readLines(con) | |
close(con) | |
tmp <- gsub("<![CDATA[", "", corrupt, fixed=TRUE) #do I really need "<![CDATA"? | |
file <- gsub("]]>", "", tmp, fixed=TRUE) #do I really need "]]>"? | |
doc <- xmlParseString(xml(file)) | |
node <- getNodeSet(doc, path="/") | |
l <- xmlToList(node[[1]]) | |
l[[1]][[1]][[1]][[1]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment