1
我是新來的android我需要使用SAX解析器解析XML,我正在使用下面的代碼。如何使用SAX XML解析器解析XML
try {
/** Handling XML */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
/** Send URL to parse XML Tags */
URL sourceUrl = new URL(
"http://example.com");
/** Create handler to handle XML Tags (extends DefaultHandler) */
MyXMLHandler myXMLHandler = new MyXMLHandler();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
} catch (Exception e) {
System.out.println("XML Parsing Excpetion = " + e);
}
但它在logcat中引起了反常的錯誤。
發表您的logcat的錯誤消息。 –
它給出了什麼錯誤? –
你長了什麼樣的錯誤 – Khan