File: DiGIR.R

package info (click to toggle)
r-cran-xml 3.99-0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,688 kB
  • sloc: ansic: 6,659; xml: 2,890; asm: 486; sh: 12; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
library(XML)
url <- "http://iobis.marine.rutgers.edu/digir2/DiGIR.php"
doc <- "<request
   xmlns='http://digir.net/schema/protocol/2003/1.0'
   xmlns:xsd='http://www.w3.org/2001/XMLSchema'
   xmlns:digir='http://digir.net/schema/protocol/2003/1.0'>
 <header>
   <version>1.0.0</version>
   <sendTime>20030421T170441.431Z</sendTime>
   <source>127.0.0.1</source>
   <destination
resource='ECNASAP'>http://localhost/digir/DiGIR.php</destination>
   <type>inventory</type>
 </header>
 <inventory xmlns:dwc='http://digir.net/schema/conceptual/darwin/2003/1.0'>
   <dwc:Scientificname />
   <count>true</count>
 </inventory>
</request>"

u = paste(url, paste("doc", doc, sep = "="), sep = "?")
r = xmlTreeParse(u)

# Alternatively,
library(RCurl)
txt = getForm(url, doc = doc)
r = xmlTreeParse(txt, asText = TRUE)

#######

r = xmlTreeParse(u, useInternal = TRUE)
science.names = xpathSApply(r,"//x:record", xmlValue, namespaces = "x")