DOM4j 读取解析 xml

小例子:
/**
*  读取报文 单元测试类
*/
public static void main(String arg[]){
try {
   
File f = new File("d:/temp/reports.xml");
SAXReader reader = new SAXReader();
Document document = reader.read(f);

                        String xpath = ""//Packet/Head/RequestType";//节点名
                        Node nodeTmp = node.selectSingleNode(xpath);
                       
                        if(nodeTmp!=null){
String value = nodeTmp.getText();
                        System.out.println(xpath +"值为"+value);
                        }


} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

你可能感兴趣的:(xml,单元测试,F#)