public class Test{
  public static void main(String[] args) throws Exception{

    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build("kk.xml");
    Element root = doc.getRootElement();

    XPath xpath = XPath.newInstance("//电话[../姓名='张三'][@类型='家庭']");
     List list = xpath.selectNodes(root);

     Iterator iter = list.iterator();
     while (iter.hasNext()) {
       Element item = (Element) iter.next();
       System.err.println(item.getText());
     }


  }

相关文章:

  • 2022-12-23
  • 2021-10-29
  • 2021-07-10
  • 2021-06-16
  • 2022-12-23
  • 2022-03-06
  • 2022-02-12
猜你喜欢
  • 2021-06-26
  • 2022-12-23
  • 2021-07-25
  • 2021-10-10
  • 2022-12-23
  • 2021-06-09
相关资源
相似解决方案