Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android如何从.aspx提要获取提要?_Android_Rss_Feed - Fatal编程技术网

Android如何从.aspx提要获取提要?

Android如何从.aspx提要获取提要?,android,rss,feed,Android,Rss,Feed,当我尝试读取.aspx提要时,应用程序会给我一个错误。 我想这是我使用的XmlParser文件。可以很好地处理.xml提要,但是当我试图使用它来读取.aspx提要时,只会给出一个错误 有什么可以帮忙的吗 多谢各位 错误消息是:05-16 13:30:31.296:E/错误:1117:PI不能以xml位置开头:未知xm@1:7在java.io中。StringReader@2fe98718 XmlParser文件的代码 // constructor public XMLParser() { }

当我尝试读取.aspx提要时,应用程序会给我一个错误。 我想这是我使用的XmlParser文件。可以很好地处理.xml提要,但是当我试图使用它来读取.aspx提要时,只会给出一个错误

有什么可以帮忙的吗

多谢各位

错误消息是:05-16 13:30:31.296:E/错误:1117:PI不能以xml位置开头:未知xm@1:7在java.io中。StringReader@2fe98718

XmlParser文件的代码

// constructor
public XMLParser() {

}

/**
 * Getting XML from URL making HTTP request
 * @param url string
 * */
public String getXmlFromUrl(String url) {
    String xml = null;

    try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        xml = EntityUtils.toString(httpEntity);

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // return XML
    return xml;
}

/**
 * Getting XML DOM element
 * @param XML string
 * */
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(is); 

        } catch (ParserConfigurationException e) {
            Log.e("Error: ", e.getMessage());
            return null;
        } catch (SAXException e) {
            Log.e("Error: ", e.getMessage());
            return null;
        } catch (IOException e) {
            Log.e("Error: ", e.getMessage());
            return null;
        }

        return doc;
}



/** Getting node value
  * @param elem element
  */
 public final String getElementValue( Node elem ) {
     Node child;
     if( elem != null){
         if (elem.hasChildNodes()){
             for( child = elem.getFirstChild(); child != null; child = child.getNextSibling() ){
                 if( child.getNodeType() == Node.TEXT_NODE  ){
                     return child.getNodeValue();
                 }
             }
         }
     }
     return "";
 }

 /**
  * Getting node value
  * @param Element node
  * @param key string
  * */
 public String getValue(Element item, String str) {     
        NodeList n = item.getElementsByTagName(str);        
        return this.getElementValue(n.item(0));
    }

}好的,从我的搜索中。这似乎是BOM编码错误。看看这两种解决方案,看看它们是否能解决您的问题


你能发布错误消息吗?嗨,安坎托斯,我已经编辑了控制台错误消息的问题。非常感谢。