XPath concat multiple nodes

流过昼夜 提交于 2019-12-04 11:05:02

string-join(/file/Element3/SubElement, ',')

/File/Element3/SubElement will match all of the SubElement elements in your sample XML. What are you using to evaluate it?

If your evaluation method is subject to the "first node rule", then it will only match the first one. If you are using a method that returns a nodeset, then it will return all of them.

You can get all SubElements by using:

//SubElement

But this won't keep them grouped together how you want. You will want to do a query for all elements that contain a SubElement (basically do a search for the parent of any SubElements).

//parent::SubElement

Once you have that, you could (depending on your programming language) loop through the parents and concatenate the SubElements.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!