Quantcast
Channel: Android how to get feeds from a .aspx feed? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Android how to get feeds from a .aspx feed?

$
0
0

when i try to read from a .aspx feed, the app gives me a error. I think is the XmlParser file that i use. Works fine with .xml feeds, but when i try to use it to read that .aspx feed just give a error.

Any idea to help ?

Thank you.

The error message is: 05-16 13:30:31.296: E/Error:(1117): PI must not start with xml (position:unknown xm@1:7 in java.io.StringReader@2fe98718)

Code of XmlParser file

// constructorpublic 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));    }

}


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images