开发者

Java Android XML parsing, can't connect to website?

Been stuck all day long with this problem, been trying to retrieve XML from this website:

http://www.teamliquid.net/video/streams/?xml=1&filter=live

But I just can't connect, I can find connect to it via google etc, but when I try to connect via the emulator using XML parsing, it won't work. But I can connect to Google weather etc..

Here is what says if you wanna use the XML document:

Thinking of scraping this page for stream data? Please use our XML feed instead: http://www.teamliquid.net/video/streams?xml=1&filter=live

gzip encoding is required, please also send a valid User-Agent with the name of your application / site and contact info. This page and the XML are updated every five minutes, please do not poll more frequently than every five minutes or you may risk being IP banned. If you have any questions, please PM R1CH.

So I'ave tryed it 2 ways, 1st code example, using a XMLReader:

private void DownloadXML()
{
    URL website;
    try{
        website = new URL("http://www.teamliquid开发者_运维百科.net/video/streams/?xml=1&filter=live");
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();
        rp = new RetrievePlayers();
        xr.setContentHandler(rp);
        xr.parse(new InputSource(website.openStream()));


    }catch(Exception e) {
        setText(""+e);
    }
}

2nd Example, using a GZIPInputStream, seing as it said somthing about GZIP encryption.

private void DownloadXML()
{
    InputStream in = null;
    GZIPInputStream gin = null;
    URL website;
    try{
        website = new URL("http://www.teamliquid.net/video/streams/?xml=1&filter=live");
        in = website.openStream();
        gin = new GZIPInputStream(in);

        BufferedReader reader = new BufferedReader(new InputStreamReader(gin));

        setText(reader.readLine());

    }catch(Exception e) {
        setText(""+e);
    }
 }

Both these codes generate a java.io.Exception.FileNotFoundException Why can't I get it? I can see the XML file with Google chrome :>

Sorry, I'm pretty new to XML, only spent 2 days working with it :/


I am going to be that guy, could it be that you do not have internet permission set in your manifest? I mean, you are parsing from a website, so if you do not have permission to get to the web, then you won't get a parsing response.

Just a Theory and I am trying to help you problem solve :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜