pat*_*tel 8 xml xpath selectnodes
我想选择带有条件Xpath的xml节点 -
xmlnode.SelectSingleNode("if (ns:substanceAdministration/ns:consumable/@typeCode == UNK) then evaluateThisXpath else evaluateOtherXpath")
Run Code Online (Sandbox Code Playgroud)
我担心的是 -
<drugID code="UNK">
<sub code="2232" />
</drugID>
Run Code Online (Sandbox Code Playgroud)
如果父节点的@code是UNK,那么只有它应该取子节点的@code值,否则取父@code值.
这应该做的伎俩:
(drugID[@code='UNK']/sub)|(drugID[@code<>'UNK')
Run Code Online (Sandbox Code Playgroud)
它是Xpath伪代码,将其更改为您的库语言
用途:
drugId[@code = 'UNK']/sub/@code | drugId/@code[not(. = 'UNK')]
Run Code Online (Sandbox Code Playgroud)
可以"缩写":
(drugId[@code = 'UNK']/sub | drugId[not(@code = 'UNK')])/@code
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13662 次 |
最近记录: |