1 Reply Latest reply: Apr 4, 2013 7:09 AM by dadams07 RSS

    Reading Child Elements From a Xml

      I am writing a generic parser program to read the xml,as we are having more than 30 different xsd, writing one single generic parser.
      I tried to parse the xml file in using xmlObject, but when i try to iterate it by reading child Nodes it doesn't get the values, where as if I use DocumentBuilderFactory to parse the xml I can able to read the child Nodes.
      Below is the code snippet

      XmlObject object = XmlObject.Factory.parse(new File("C://backup//test.xml");
      NodeList nodeList = object.getDomNode().getChildNodes()
      *for (int i = 0; i < nodeList.getLength(); i++) {*
      *               Node textChild = nodeList.item(i);*
      *               NodeList childNodes = textChild.getChildNodes();*
      *               populate( childNodes , idx + 1 , nodeList.item(i) , input );*
      *          }*

      If any one have any idea of writing generic parser. plz share your ideas.
        • 1. Re: Reading Child Elements From a Xml
          Unless this is a school assignment, I'd back up a step and ask why you're trying to write an XML parser in the first place? This is a very advanced task, and should be attempted only by experienced developers, and then only if one of the many fine existing parsers don't meet your needs.