dom4j 解析xml字符串

 

/**

*path xml字符串

*ndename 节点名称

*/

public static Node analytic(String path, String nodeName) {
  Document doc = null;
  try {
   doc = DocumentHelper.parseText(path);
  } catch (DocumentException e) {   
   e.printStackTrace();
  }
  XPath xpathSelector = DocumentHelper.createXPath(nodeName);
  Node node = xpathSelector.selectSingleNode(doc);
  return node;
 }

你可能感兴趣的:(dom4j)