Going Further in TEI exploration. This is my XML Tei file containing \"date\" nodes with different attributes (when, from, to). I have sucessfully extracted the value of \"when
Couldn't you do something like this
sapply(c("when","from"), function(x) xpathSApply(doc, '//date', xmlGetAttr, x))
For a reproducible example, I'll use a PLOS One article in xml format.
library(XML)
doc <- xmlParse("http://www.plosone.org/article/fetchObjectAttachment.action?uri=info%3Adoi%2F10.1371%2Fjournal.pone.0084312&representation=XML")
sapply(c("contrib-type","xlink:type"), function(x) xpathSApply(doc, '//contrib', xmlGetAttr, x))
contrib-type xlink:type
[1,] "author" "simple"
[2,] "author" "simple"
[3,] "author" "simple"
[4,] "author" "simple"
[5,] "author" "simple"
[6,] "editor" "simple"