library(XML) xmlfile2 <- xmlTreeParse("pubmed_result.xml") # Use the xmlRoot-function to access the top node xmltop2 <- xmlRoot(xmlfile2) xmlName(xmltop2) # root is an article set # have a look at the XML-code of the first subnodes: num_articles <- xmlSize(xmltop2) xmlName(xmltop2[[1]]) # Pub med article xmltop2[[1]] # retrieve the pubmed article xmlName(xmltop2[[1]][[2]]) # "PubmedData" xmltop2[[1]][[2]] # pubmed data xmlName(xmltop2[[1]][[2]][[1]]) #History element xmltop2[[1]][[2]][[1]] # History element xmlName(xmltop2[[1]][[2]][[1]][[1]]) #PubMedPubDate xmltop2[[1]][[2]][[1]][[1]] # History element