我的XML:
<root>
<child>
<childOfChild>
<anotherLostChild>
<currentSelectedNode>
SOME TEXT
</currentSelectedNode>
</anotherLostChild>
</childOfChild>
</child>
</root>
Run Code Online (Sandbox Code Playgroud)
我使用以下方法选择了节点currentSelectedNode:
xpath.SelectSingleNode("//currentSelectedNode")
Run Code Online (Sandbox Code Playgroud)
但是,如何返回选择第一个chilfOfChild父节点(考虑到上下文是currentSelectedNode?
xpath.SelectSingleNode("//currentSelectedNode")...???
Run Code Online (Sandbox Code Playgroud)
ann*_*ata 13
你的问题真的很混乱,但听起来你想要祖先的轴,比如:
//currentSelectedNode/ancestor::childOfChild[1]
Run Code Online (Sandbox Code Playgroud)
(纯xpath解决方案)
归档时间: |
|
查看次数: |
15172 次 |
最近记录: |