title: Geocoding in R with Google Maps
body: <p>I've tried running the code to geocode locations in R via Google Maps and the <code>XML</code> package from this blog post:
  <a href="http://www.r-chart.com/2010/07/maps-geocoding-and-r-user-conference.html" rel="noreferrer">http://www.r-chart.com/2010/07/maps-geocoding-and-r-user-conference.html</a></p>
  
  <p>Here are his functions:</p>
  
  <pre><code>getDocNodeVal=function(doc, path){
    sapply(getNodeSet(doc, path), function(el) xmlValue(el))
  }
  
  gGeoCode=function(str){
    library(XML)
    u=paste('http://maps.google.com/maps/api/geocode/xml?sensor=false&amp;address=',str)
    doc = xmlTreeParse(u, useInternal=TRUE)
    str=gsub(' ','%20',str)
    lng=getDocNodeVal(doc, "/GeocodeResponse/result/geometry/location/lat")
    lat=getDocNodeVal(doc, "/GeocodeResponse/result/geometry/location/lng")
    c(lat,lng)
  }
  </code></pre>
  
  <p>When I run <code>gGeoCode()</code>, I get the following error:</p>
  
  <pre><code>&gt; gGeoCode("Philadelphia, PA")
  failed to load external entity "http%3A//maps.google.com/maps/api/geocode/xml%3Fsensor=false&amp;address=%20Philadelphia,%20PA"
  Error: 1: failed to load external entity "http%3A//maps.google.com/maps/api/geocode/xml%3Fsensor=false&amp;address=%20Philadelphia,%20PA"
  </code></pre>
  
  <p>If I just paste into a browser the API url with <code>Philadelphia, PA</code> appended to the end, like the string passed to <code>xmlParseTree</code>, I get a result that looks like legitimate xml when I download it.</p>
  
  <p>Is this an issue with the code, or have I failed to configure something or another?</p>