SAXParser에 XML 페이지를 변수로 전달하는 데 문제가 있습니다. 아래 코드는 URL을 가져 와서 SAXParser에 전달하려고 시도하지만 오류가 발생합니다.SAXParser XML에 http url 전달
그러나 URL을 명시 적으로 정의하면 (변수를 사용하는 것이 아니라) 작동하면 좋습니다. 아무도 왜 이것이 실패하지 않습니다.
도움을 주실 수있는 분들께 감사드립니다. 나는 목적을보기 위해 코드를 잘라 냈다.
public class Parser extends DefaultHandler
private String link;
public void parseDocument() {
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
SAXParser sp = spf.newSAXParser();
link = coll.getGcollId(id); // this successfully gets a string (url) to link to xml page over http string
//parse the file and also register this class for call backs
sp.parse(link, this); // when I run this code this line gets a "java.io.FileNotFoundException: http://foo.com/foo.xml"
이 http://foo.com/foo.xml가 올바른지되어 사용? – kosa
아니요 코드를 모두 줄이려고했습니다. 오류의 출력은 올바른 URL입니다. – chuck