Skip to content

Instantly share code, notes, and snippets.

@dwtkns
Forked from sandsfish/getMARCField Example.r
Created February 15, 2013 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwtkns/4962044 to your computer and use it in GitHub Desktop.
Save dwtkns/4962044 to your computer and use it in GitHub Desktop.
library(XML)
getMARCField = function(marc_doc, tag, code) {
xpath = paste("/m:collection/m:record/m:datafield[@tag='", tag, "']/m:subfield[@code='", code, "']", sep="")
return(xpathApply(marc_doc, xpath, namespaces=c("m"), xmlValue))
}
vs = xmlRoot(xmlParse('vail-first-3500.xml'))
field100a = getMARCField(vs, '100', 'a')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment