Skip to content

Commit

Permalink
Merge pull request #269 from wdwatkins/waterML2_xml2
Browse files Browse the repository at this point in the history
importWaterML2 to xml2
  • Loading branch information
ldecicco-USGS authored Aug 26, 2016
2 parents d3ff929 + 012f8c5 commit a58589f
Show file tree
Hide file tree
Showing 10 changed files with 289 additions and 484 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Imports:
stats,
utils,
dplyr,
xml2,
readr (>= 1.0.0)
Suggests:
xtable,
Expand Down
18 changes: 10 additions & 8 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,13 @@ export(zeroPad)
import(lubridate)
import(stats)
import(utils)
importFrom(XML,xmlAttrs)
importFrom(XML,xmlDoc)
importFrom(XML,xmlName)
importFrom(XML,xmlNamespaceDefinitions)
importFrom(XML,xmlParse)
importFrom(XML,xmlRoot)
importFrom(XML,xmlSize)
importFrom(XML,xmlToList)
importFrom(XML,xmlTreeParse)
importFrom(XML,xmlValue)
importFrom(XML,xpathApply)
importFrom(XML,xpathSApply)
importFrom(curl,curl_version)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_rows)
importFrom(dplyr,full_join)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate_)
Expand All @@ -76,3 +70,11 @@ importFrom(readr,read_delim)
importFrom(readr,read_lines)
importFrom(reshape2,dcast)
importFrom(reshape2,melt)
importFrom(xml2,read_xml)
importFrom(xml2,xml_attr)
importFrom(xml2,xml_attrs)
importFrom(xml2,xml_children)
importFrom(xml2,xml_find_all)
importFrom(xml2,xml_name)
importFrom(xml2,xml_root)
importFrom(xml2,xml_text)
15 changes: 0 additions & 15 deletions R/getWebServiceData.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ getWebServiceData <- function(obs_url, ...){

if(headerInfo$`content-type` == "text/tab-separated-values;charset=UTF-8"){
returnedDoc <- content(returnedList, type="text",encoding = "UTF-8")
} else if (headerInfo$`content-type` %in% c("text/xml;charset=UTF-8",
"text/xml")){
returnedDoc <- xmlcontent(returnedList)
} else if (headerInfo$`content-type` == "text/html"){
txt <- readBin(returnedList$content, character())
message(txt)
Expand Down Expand Up @@ -68,18 +65,6 @@ default_ua <- function() {
paste0(names(versions), "/", versions, collapse = " ")
}

#' drop in replacement for httr switching to xml2 from XML
#'
#' reverts to old parsing pre v1.1.0 for httr
#'
#' @param response the result of httr::GET(url)
#' @keywords internal
#' @importFrom XML xmlParse
xmlcontent <- function(response){
XML::xmlTreeParse(iconv(readBin(response$content, character()), from = "UTF-8", to = "UTF-8"),
useInternalNodes=TRUE,getDTD = FALSE)
}

#' getting header information from a WQP query
#'
#'@param url the query url
Expand Down
Loading

0 comments on commit a58589f

Please sign in to comment.