What is the wrong with the following code?

조회 수: 3 (최근 30일)
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah 2016년 5월 6일
편집: K M Ibrahim Khalilullah 2016년 5월 10일
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
Adam
Adam 2016년 5월 6일
편집: Adam 2016년 5월 6일
It can't find the file. Check that the file you are giving it is actually a valid full path.

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2016년 5월 6일
편집: Guillaume 2016년 5월 6일
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
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah 2016년 5월 10일
편집: K M Ibrahim Khalilullah 2016년 5월 10일
Thanks, At last I have solved. but xmlread can read urls....

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by