0

Here is my code

 DOMParser myparser = DOMParser.getInstance();
                        myparser.parse(response.trim());
                        Document myDoc = myparser.getDocument();

                        NodeList nList = myDoc.getElementsByTagName("ValidationError");

                        for (int temp = 0; temp < nList.getLength(); temp++) {
                            Node nNode = nList.item(temp);

                            if (nNode.getNodeType() == Node.ELEMENT_NODE) {


                                    errorOb.setError(errorMassage);
                                errorOb.setErrorCode(errorCode);


                            }
                        }

This code is working fine but each and every time It checked node name and take value(ValidationError) .Without specific node name how can we do this?

  • Where are u checking node name? you are already calling right API using NodeList nList = myDoc.getElementsByTagName("ValidationError") . Go to Node and getAttribute("name") – Optional Sep 26 '17 at 07:06
  • As an example i have got this I could get cod and text through this but if the name change ValidationError then it is not working .I need to know a way for get this code and text without specific name ValidationError – Prageeth Perumbuli Sep 26 '17 at 07:53
  • Attribute is part of an element. So you will have to build a generic method where you either parse all elements and then look out for attributes, or write a method take takes name of node. e.g ValidationError, newValidationError etc and then use this passed string to find your getElementsByTagName(passedName) – Optional Sep 26 '17 at 08:23

0 Answers0