【发布时间】:2012-06-28 21:58:25
【问题描述】:
我是 android 开发的初学者。我将 SAX 解析器用于 xml 解析器。我找不到这个例外的原因。 我尝试了 getAsset() 方法。但它没有用。
xmlParser 代码:::
public class XMLParser {
public static Country parseCountry(InputStream is) {
try {
Country country= new Country(null, null, null);
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
XMLHandler xmlHandler = new XMLHandler();
xmlReader.setContentHandler(xmlHandler);
xmlReader.parse(new InputSource(new FileInputStream(http://64.85.165.53/dharatest/xmlarray.xml));
country = xmlHandler.getParsedCountryData();
} catch(ParserConfigurationException pce) {
Log.e("SAX XML", "sax parse error", pce);
} catch(SAXException se) {
Log.e("SAX XML", "sax error", se);
} catch(IOException ioe) {
Log.e("SAX XML", "sax parse io error", ioe);
}
return country;
}
}
【问题讨论】:
-
new FileInputStream("http://64.85.165.53/dharatest/xmlarray.xml")??? -
您需要先从该网址下载您的 .xml 文件,然后您才能读取/解析该 XML。
标签: android inputstream saxparser filenotfoundexception