What is the wrong with the following code?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
K M Ibrahim Khalilullah
am 6 Mai 2016
Bearbeitet: K M Ibrahim Khalilullah
am 10 Mai 2016
address='1217 fayettevelle St., Durham, NC';
SERVER_URL = 'http://maps.google.com';
address = regexprep(address, ' ', '+');
queryUrl = sprintf('%s/maps/geo?output=xml&q=%s',SERVER_URL, address);
docNode = xmlread(queryUrl)
It is showing the following error:
Error using xmlread (line 97) Java exception occurred: java.io.FileNotFoundException: http://maps.google.com/maps/geo?output=xml&q=1217+fayettevelle+St.,+Durham,+NC
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
Error in Untitled2 (line 11) docNode = xmlread(queryUrl)
1 Kommentar
Akzeptierte Antwort
Guillaume
am 6 Mai 2016
Bearbeitet: Guillaume
am 6 Mai 2016
xmlread does not read urls, only files. To read urls you can use webread. I believe the following should work if http://maps.google.com/maps/geo were a valid URL at (unfortunately, it 404):
address='1217 fayettevelle St., Durham, NC';
SERVER_URL = 'http://maps.google.com';
address = regexprep(address, ' ', '+');
fullurl = sprintf('%s/maps/geo', SERVER_URL);
domnode = webread(fullurl, 'output', 'xml', 'q', address, weboptions('ContentType', 'xmldom'))
1 Kommentar
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!