I'm writing a script that takes a RSS and phrases items.. but it is crashing on part of the code.
I'm using the code from: http://www.devx.com/wireless/Article/39810/1954 private void DownloadRSS(String URL) { InputStream in = null; try { in = OpenHttpConnection(URL); Document doc = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); doc = db.parse(in); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } doc.getDocumentElement().normalize(); //---retrieve all the <item> nodes--- NodeList itemNodes = doc.getElementsByTagName("item"); String strTitle = ""; for (int i = 0; i < itemNodes.getLength(); i++) { Node itemNode = itemNodes.item(i); if (itemNode.getNodeType() == Node.ELEMENT_NODE) { //---convert the Node into an Element--- Element itemElement = (Element) itemNode; //---get all the <title> element under the <item> // element--- NodeList titleNodes = (itemElement).getElementsByTagName("title"); //---convert a Node into an Element--- Element titleElement = (Element) titleNodes.item (0); //---get all the child nodes under the <title> element--- NodeList textNodes = ((Node) titleElement).getChildNodes(); //---retrieve the text of the <title> element--- strTitle = ((Node) textNodes.item(0)).getNodeValue (); //---display the title--- Toast.makeText(getBaseContext(),strTitle, Toast.LENGTH_SHORT).show(); } } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } It is crashing the app when it gets to: doc.getDocumentElement ().normalize(); (And it won't work without it.. Some work.. some RSS files do not.) Is this the best way to do it? I want to load the fields "title" and "link" into an array.. and then list them and make it clickable. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---