如何使用xpath连接多个节点

Gre*_*Dan 2 xml xml-parsing xpath-2.0

我正在寻找一种方法来使用Xpath 2.0获取以下字符串:

AAA-Site-1.test.com,BBB-Site-1.test.com

<SystemRoot SystemName='Xpath Test'>
     <SystemRoot SystemDomain='test.com' SystemName='AAA-Site-1'>
      <Product InstallDate='11/01/2012' ProductName='AAA'/>
    </SystemRoot>
    <SystemRoot SystemDomain='test.com' SystemName='BBB-Site-1'>
      <Product InstallDate='11/01/2012' ProductName='BBB'/>
    </SystemRoot>
</SystemRoot>
Run Code Online (Sandbox Code Playgroud)

我试过concat然后串联,但我得到"太多的价值"......

concat(/SystemRoot/SystemRoot/@SystemDomain,'.',/SystemRoot/SystemRoot/@SystemName)
Run Code Online (Sandbox Code Playgroud)

是否可以通过仅使用XPath 2.0来实现?

Fre*_*Foo 7

是的,这是可能的:

string-join(/SystemRoot/SystemRoot/concat(@SystemName, ".", @SystemDomain),
            ",")
Run Code Online (Sandbox Code Playgroud)