我正在尝试将 XPath 应用于具有以下结构的 XML 文件:
XPath:/root/tour/round/event/parent::round/@name
预期的输出是:
final
semifinal
semifinal
quarterfinal
quarterfinal
quarterfinal
quarterfinal
round3
但我没有得到上述输出,而是这样:
final
semifinal
quarterfinal
round3
对于获得预期输出的任何帮助,我将不胜感激。
XML 文件
<root>
<tour>
<round name="final">
<event>Test</event>
</round>
<round name="semifinal">
<event>Test</event>
<event>Test</event>
</round>
<round name="quarterfinal">
<event>Test</event>
<event>Test</event>
<event>Test</event>
<event>Test</event>
</round>
<round name="round3">
<event>Test</event>
<event>Test</event>
<event>Test</event>
<event>Test</event>
</round>
</tour>
</root>