zoukankan      html  css  js  c++  java
  • A powerful tool to parse xml -- Xpath!

    The Xpath's javadoc could be got from the Dom4j's javadoc.

    There are some simple regulation you must follow:

      1.When you want to use specific single node:

        /AAA

        /AAA/CCC

      2.When you want to use all the nodes which have the same name:

        //BBB

        //DDD/CCC

      3. * represent all the nodes in the specific path:

        /AAA/*

        //*     --------->  all the nodes

      4.The expression which has the square brackets could further specify the node. The number in the bracket gives the position you select/

        /AAA[1]

        //BBB/CCC[last()]

      5.The attribute will be got by the @

        //@id

        /AAA[@id]

    But after knowing the regulation , where should we put it?

      //Get the document object

      SAXReader reader = new SAXReader();

      Document document = reader.read("");

      //get the data of node via document's selecNodes() or selectSingleNode()

      List<Node> nodes = document.selectNodes(" you can set your regulation here!!");

      Node node = document.selectSingleNode(" you can set your regulation here!!");

      

  • 相关阅读:
    OCP-1Z0-052-V8.02-157题
    OCP-1Z0-052-V8.02-72题
    error C2061: 语法错误 : 标识符“_DebugHeapTag”
    OCP-1Z0-052-V8.02-23题
    OCP-1Z0-052-V8.02-77题
    vc2005 使用Boost库的编译步骤.
    OCP-1Z0-052-V8.02-79题
    OCP-1Z0-052-V8.02-82题
    OCP-1Z0-052-V8.02-81题
    OCP-1Z0-052-V8.02-80题
  • 原文地址:https://www.cnblogs.com/ppcoder/p/7162047.html
Copyright © 2011-2022 走看看