How to select multiple nodes in different levels?

前端 未结 3 1071
遥遥无期
遥遥无期 2021-02-19 00:14

Having this (simplified) XML:




        
            Pol         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 00:24

    Use:

    /*/*/Placemark/name | /*/*/Placemark/*/coordinates
    

    This specifies the union of the results of two separate XPath expressions -- the standard XPath union operator | is used. Selected are all name elements that are children of a Placemark element that is a grandchild of the top element of the XML document, plus all coordinates elements that are grand-children of a Placemark element that is a grandchild of the top element of the XML document.

    The selected elements come in document order (although no normative W3C document specifies the order), which means that in the result of the evaluation (usually of type XmlNodeList) any name element is directly followed by its corresponding coordinates element.

提交回复
热议问题