Hi, I was having problem in using DOM parser for SDK 1.6 , it was
working properly on SDK 2.2. Now I figured it out. Thought of sharing
it so that others dont have to waste their time. Here is the solution
to make this thing work
private void parseXMLResponse(String xml) throws Exception{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new
StringReader(xml)));
doc.getDocumentElement().normalize();
String docType = doc.getDocumentElement().getTagName();
Node node ;
Element ele = doc.getDocumentElement();
Log.i("Node is", " hii "+ele.getChildNodes().getLength());
NodeList nodes = ele.getChildNodes();
responsetype = docType;
for(int i = 0; i<nodes.getLength(); i++){
node = nodes.item(i);
if (node.getNodeType() == 1){
responsevalues.put(node.getNodeName(),
node.getFirstChild().getNodeValue());
}
}
}
xml : your xml string
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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