Синтаксический анализ XML с помощью Child, а не разбор значений

Синтаксический анализ XML с помощью Child, а не разбор значений

   import java.io.File;
   import java.io.FileInputStream;

   import javax.xml.xpath.XPath;
   import javax.xml.xpath.XPathConstants;
   import javax.xml.xpath.XPathFactory;

   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
   import org.xml.sax.InputSource;

   import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList;

    public class XPathEvaluator {
    /*
   * ServiceGroup serviceGroup = new ServiceGroup(); List<Service>
    * requiredServices = new ArrayList<Service>(); List<Service>
  * recommandedServices = new ArrayList<Service>(); Service service = new
  * Service();
  */

public void evaluateDocument(File xmlDocument) {

    try {
        XPathFactory factory = XPathFactory.newInstance();
        XPath xPath = factory.newXPath();
        String requiredServicesExpression = "/Envelope/Header";
        InputSource requiredServicesInputSource = new InputSource(
                new FileInputStream(xmlDocument));
        DTMNodeList requiredServicesNodes = (DTMNodeList) xPath.evaluate(
                requiredServicesExpression, requiredServicesInputSource,
                XPathConstants.NODESET);
        System.out.println(requiredServicesNodes.getLength());
        NodeList requiredNodeList = (NodeList) requiredServicesNodes;

        for (int i = 0; i < requiredNodeList.getLength(); i++) {
            Node node = requiredNodeList.item(i);
            System.out.println(node.getChildNodes());

        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static void main(String[] argv) {
    XPathEvaluator evaluator = new XPathEvaluator();
    File xmlDocument = new File("d://eva.xml");
    evaluator.evaluateDocument(xmlDocument);

 }

}

мой XML следующий в этом я пытаюсь разобрать информацию заголовка

   <?xml version="1.0" encoding="UTF-8"?>
   <Envelope>
       <Header>
            <User id="MAKRISH"/>
            <Request-Id id="1"/>
            <Type name="Response"/>
            <Application-Source name="vss" version="1.0"/>
            <Application-Destination name="test" />
            <Outgo-Timestamp date="2012-08-24" time="14:50:00"/>
            <DealerCode>08301</DealerCode>
            <Market>00000</Market>
        </Header>
   </Envelope>

я не могу получить дочерний заголовок, как я могу получить их, это дает мне нулевой метод getchildNodes. У меня есть проверка для многих решений, но получить любую вещь.

Ответы на вопрос(2)

Ваш ответ на вопрос