Hi members,
                    Using DOMParser i m able to retrieve XML data from my 
database.Now i need to pass the "name" which i retrieved  to other class 
using intenet,but i m not able to read it here is my code :

 void parseByDOM(String response) throws ParserConfigurationException, 
SAXException, IOException {//response is ur xml as string 
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(new InputSource(new 
StringReader(response)));
        // normalize the document
        doc.getDocumentElement().normalize();
        // get the root node
        NodeList nodeList = doc.getElementsByTagName("user");
        Node node=nodeList.item(0);
        // the  node has three child nodes
        for (int i = 0; i < node.getChildNodes().getLength(); i++) {
        Node temp=node.getChildNodes().item(i);
        if(temp.getNodeName().equalsIgnoreCase("name")){
         String name = temp.getTextContent();
         System.out.println("name :"+name);

        }
        else if(temp.getNodeName().equalsIgnoreCase("mail")){
         String mail=temp.getTextContent();
        }
        else if(temp.getNodeName().equalsIgnoreCase("phno")){
         String phno=temp.getTextContent();
        }

        }
        
        Intent i = new Intent(getApplicationContext(), test.class);
        i.putExtra(name,name);
        startActivity(i);
       }


and in my test.java i m using like this :

name.setText(getIntent().getStringExtra("name"));

-- 
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

Reply via email to