<NETCAST>
<ACTION NParam="7" ShortName="shot" Quarter="1" Position="27">
<PARAM Data="2" Name="Team"/>
<PARAM Data="2" Name="Player"/>
<PARAM Data="0" Name="Made"/>
<PARAM Data="2" Name="Points"/>
<PARAM Data="1" Name="AddFlags"/>
</ACTION>
<ACTION NParam="2" ShortName="assist" Quarter="1" Position="28">
<PARAM Data="2" Name="Team"/>
<PARAM Data="21" Name="Player"/>
</ACTION>
<ACTION NParam="7" ShortName="shot" Quarter="1" Position="29">
<PARAM Data="1" Name="Team"/>
<PARAM Data="21" Name="Player"/>
<PARAM Data="0" Name="Made"/>
<PARAM Data="3" Name="Points"/>
<PARAM Data="0" Name="AddFlags"/>
</ACTION>
<ACTION NParam="7" ShortName="shot" Quarter="1" Position="30">
<PARAM Data="2" Name="Team"/>
<PARAM Data="32" Name="Player"/>
<PARAM Data="0" Name="Made"/>
<PARAM Data="3" Name="Points"/>
<PARAM Data="4" Name="AddFlags"/>
</ACTION>
<ACTION NParam="3" ShortName="reb" Quarter="1" Position="31">
<PARAM Data="1" Name="Team"/>
<PARAM Data="-2" Name="Player"/>
<PARAM Data="1" Name="Type"/>
</ACTION>
<ACTION NParam="7" ShortName="shot" Quarter="1" Position="32">
<PARAM Data="1" Name="Team"/>
<PARAM Data="15" Name="Player"/>
<PARAM Data="1" Name="Made"/>
<PARAM Data="2" Name="Points"/>
<PARAM Data="3" Name="AddFlags"/>
</ACTION>
</NETCAST>
我需要XPATH查询的帮助才能选择
行动/参与[@Name =&#34;积分&#34;] /数据(按照todo SUM的顺序)
其中
行动[NParam =&#34; 7&#34;] AND
ACTION / PARAM [@Name =&#34; Team&#34;] [Data =&#34; 1&#34;] AND
ACTION / PARAM [@Name =&#34; Made&#34;] [Data =&#34; 0&#34;] AND
ACTION / PARAM [@Name =&#34; AddFlags&#34;] [数据=&#34; 1&#34;或&#34; 3&#34;或&#34; 4&#34;]
我知道如何选择但只使用一个孩子!!!
/NETCAST/ACTION[NParam=7]/PARAM[@Name="Points"]/@Data
提前感谢您的帮助。
答案 0 :(得分:1)
目前尚不清楚预期的输出是什么。假设您希望根据多个ACTION
的属性找到符合多个条件的PARAM
,您可能需要遵循以下XPath示例:
/NETCAST
/ACTION[
@NParam=7 and
PARAM[@Name="Team" and @Data="1"] and
PARAM[@Name="Made" and @Data="0"] and
PARAM[@Name="AddFlags"][@Data="0" or @Data="3" or @Data="4"]
]
<强> xpath demo
强>
鉴于此问题中的XML作为输入,输出将为:
<ACTION NParam="7" ShortName="shot" Quarter="1" Position="29">
<PARAM Data="1" Name="Team"/>
<PARAM Data="21" Name="Player"/>
<PARAM Data="0" Name="Made"/>
<PARAM Data="3" Name="Points"/>
<PARAM Data="0" Name="AddFlags"/>
</ACTION>