Select an XML element regardless of level with XPATH

后端 未结 4 1901
無奈伤痛
無奈伤痛 2021-02-05 06:48

I have this:


  
    text
  


  text

So I want

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 07:40

    You are looking for the descendant axis:

    the descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on; thus the descendant axis never contains attribute or namespace nodes

    In your case: /descendant:t

    Of course, as others have answered, there is an abbreviated syntax for this:

    // is short for /descendant-or-self::node()/. For example, //para is short for /descendant-or-self::node()/child::para and so will select any para element in the document (even a para element that is a document element will be selected by //para since the document element node is a child of the root node)

提交回复
热议问题