2

我一直在尝试使用 SAX XML 解析器来访问服务器上的一些数据,但无论我应用了多少不同的教程和方法测试了多少,数据变量每次都会出现空。
我尝试使用本地文件,但也成功了。最后在一些教程评论中,我从 3,0+ api Android 更改了获取和流式传输文件的方法。我发现我需要创建一个不同的线程来传输数据。你能帮我吗?我只需要让这些线路正常工作:

SAXParserFactory saxPF = SAXParserFactory.newInstance();
SAXParser saxP = saxPF.newSAXParser();
XMLReader xmlR = saxP.getXMLReader();
URL url = new URL("http://www.xmlfiles.com/examples/cd_catalog.xml"); // URL of the XML
/**
* Create the Handler to handle each of the XML tags.
**/
XMLHandler myXMLHandler = new XMLHandler();
xmlR.setContentHandler(myXMLHandler);
xmlR.parse(new InputSource(url.openStream()));
4

0 回答 0