java.net.malformedurlexception协议未找到android

时间:2013-09-19 19:44:33

标签: java android xml protocols

我正在尝试使用Http中的Rss XML,我使用了这个数学代码:

public String getXMLfromUrl(String url){
    String xml = null;
    try{
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        HttpResponse httpResponse = httpclient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        xml = EntityUtils.toString(httpEntity);
    }catch(Exception e){
        Log.e(" getXMLfromUrl : "," ",e);
    }
    return xml;
} 


public Document getDomElement(String xml){
    Document doc = null;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try{
        DocumentBuilder db = dbf.newDocumentBuilder();

        InputSource is = new InputSource();
            is.setCharacterStream(new StringReader(xml));
            doc = db.parse(xml);
            doc.getDocumentElement().normalize();
    }catch(Exception e){
        Log.e(" getDomElement : "," ",e);
    }
    return doc;
}

但我有一个问题,第一个mathod不会返回所有XML String,所以String不是XML格式,我认为我的XML Stream太长或者我包含/ n或者可能但是包含阿拉伯字符,所以第二个Mathod抛出java.net.malformedurlexception协议找不到android,或者说我觉得....

请求帮助我

0 个答案:

没有答案