Skip to content
Snippets Groups Projects
Commit c55d5cf9 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Changing to official WaterML2 source. Still debugging.

parent 8255cce3
No related branches found
No related tags found
1 merge request!9Added a lot of error handling.
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
#' @import XML #' @import XML
#' @importFrom plyr rbind.fill.matrix #' @importFrom plyr rbind.fill.matrix
#' @examples #' @examples
#' URL <- "http://webvastage6.er.usgs.gov/ogc-swie/wml2/dv/sos?request=GetObservation&featureID=435601087432701&observedProperty=00045&beginPosition=2012-01-01&offering=Sum" #' URL <- "http://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0&sites=01646500&startDT=2014-09-01&endDT=2014-09-08&statCd=00003&parameterCd=00060"
#' dataReturned3 <- getWaterML2Data(URL) #' \dontrun{dataReturned3 <- getWaterML2Data(URL)}
getWaterML2Data <- function(obs_url){ getWaterML2Data <- function(obs_url){
h <- basicHeaderGatherer()
doc = tryCatch({ doc = tryCatch({
returnedDoc <- getURI(obs_url, headerfunction = h$update) returnedDoc <- getURL(obs_url, headerfunction = h$update)
if(h$value()["Content-Type"] == "text/xml;charset=UTF-8"){ if(h$value()["Content-Type"] == "text/xml;charset=UTF-8"){
xmlTreeParse(returnedDoc, getDTD = FALSE, useInternalNodes = TRUE) xmlTreeParse(returnedDoc, getDTD = FALSE, useInternalNodes = TRUE)
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment