Database Reference
In-Depth Information
WARNING
Are you behind a Windows firewall or proxy and this example is giving you trouble?
xmlTreeParse has no respect for your proxy settings. Do the following:
> Sys.setenv("http_proxy" = "http://myProxyServer:myProxyPort")
or if you use a username/password:
>
Sys.setenv("http_proxy"="http://username:password@proxyHost:proxyPort″)
You need to install the cURL package to handle fetching web pages:
> install.packages("RCurl")
> library("RCurl")
In the example above, change:
> xmlResult<-xmlTreeParse(requestUrl,isURL=TRUE)
to:
> xmlResult<-xmlTreeParse(getURL(requestUrl))
The XML package can perform event- or tree-based parsing. However, because we only need
two bits of information (latitude and longitude), we can go straight for the jugular by gleaning
what we can from the data structure that xmlTreeParse returns:
> str(xmlResult)
List of 2
$ doc:List of 3
..$ file :List of 1
.. ..$ Result:List of 7
.. .. ..$ Latitude :List of 1
.. .. .. ..$ text: list()
.. .. .. .. ..- attr(*, "class")= chr [1:5] "XMLTextNode" "XMLNode"
"RXMLAb...
.. .. .. ..- attr(*, "class")= chr [1:4] "XMLNode"
"RXMLAbstractNode" "XMLA...
.. .. ..$ Longitude:List of 1
.. .. .. ..$ text: list()
.. .. .. .. ..- attr(*, "class")= chr [1:5] "XMLTextNode" "XMLNode"
"RXMLAb...
.. .. .. ..- attr(*, "class")= chr [1:4] "XMLNode"
"RXMLAbstractNode" "XMLA...
(snip)
Search WWH ::




Custom Search