Android remote XML parse (document builder)

vicksanj

New Member
i have been traipsing the internet for days and i really need some help, i am trying to parse in an XML document from a web server into a ListView in android, i have worked out how to do it with a local file and that is fine, but no matter what i find whether on stack or other sites it just doesnt seem to work, can anyone help me with this?? i know the page exists and works...ive pulled all my hair out now so pleas help :)below is my code for the method, this is called after the on create and an onclicklistener for items,also i am using the document builder factory method.\[code\]private void xmlparse(){ try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); Document doc = builder.parse(new URL("URL in here").openConnection().getInputStream()); doc.getDocumentElement().normalize(); NodeList nList = doc.getElementsByTagName("item"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; titles.add(getTagValue(TITLE_1, eElement)); //TITLE_1 is the xml tag title } } } catch (Exception e) { e.printStackTrace(); }}private String getTagValue(String sTag, Element eElement) { NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes(); Node nValue = http://stackoverflow.com/questions/12761964/(Node) nlList.item(0); return nValue.getNodeValue(); }\[/code\]Am i missing something daft or have i missed the ball completely? can anyone point me to infomation which would help or just let me know :)Cheers!!
 
Back
Top