1 Reply Latest reply: Jul 18, 2009 12:50 PM by 843789 RSS

    parse a XML

      I'm parsing a xml-like file but I have few problems in using some method; for example:
      NodeList listOfStates = doc.getElementsByTagName("state"); //I have tags <state attr="value".........>; but what about if I had <State...> or <STATE>???? My istruction doens't work in    
              //these cases. How can I change it?
      State n = myobj.getStates().lastElement(); //I created a State object for my aims
      NodeList childs = listOfStates.item(  ).getChildNodes(); //here I need to search in listOfStates a particular State. How can I retrieve it using XML methods???
      thanks in advance..
        • 1. Re: parse a XML
          If you know the structure of the xml you are dealing with then use xpath. It is easy to learn.

          BTW if you want to by your way then use a loop to check each name in every node with value you have.