How to select multiple nodes from XML with XPath?

后端 未结 1 812
梦如初夏
梦如初夏 2021-01-16 18:40

What is the XPath syntax that returns multiple nodes from XML?

Say I have XML like so:


  
    
      <         


        
1条回答
  •  一整个雨季
    2021-01-16 18:58

    You can select multiple nodes in XPath, but you cannot re-arrange XML in the manner exhibited in your requested output.

    Also note:

    1. Your sample XML is not well-formed; it must have a single root element.
    2. You can indeed select multiple nodes as your title question asks using the union operator | you suggest, however...
    3. Your desired XML is not available for selection, which XPath does, but it could be constructed via transformation, which XSLT does (provided you're willing to wrap the desired XML in a single enclosing root element).

    0 讨论(0)
提交回复
热议问题