以下是我的XML,我需要使用Xpath使用<id>
值<task>/id
找到(Id)的Changeset属性值。
我尝试了以下查询"ReleaseNotes/ChangeSets/ChangeSet[Comments/checkintext/task/id ='" + jiraId + "']"
,其中jiraId为<task>id
值
<?xml version="1.0" encoding="utf-8"?>
<ReleaseNotes>
<AxVersion>6.2.1000.1437</AxVersion>
<FromDate>2/1/2015 12:00:00 AM</FromDate>
<ToDate>2/26/2015 12:00:00 AM</ToDate>
<ChangeSets>
<ChangeSet Id="3600">
<CheckInUserId>XXX\yy</CheckInUserId>
<Comments>
<checkintext>
<bpcheckdeviated>true</bpcheckdeviated>
<task>
<id>CS-2215</id>
<name>Small performance improvements in hedge qty lookup.</name>
<version>V6.0</version>
<sprint>17.8</sprint>
<project>Cs2215_Mpv_HedgeQtyLookupPerformance</project>
<area>Others</area>
<taskstatus>Closed</taskstatus>
</task>
<text>
Few small performance improvements in queries.
</text>
<notes>
<note>
<section>Info</section>
<component></component>
<text></text>
</note>
</notes>
</checkintext>
</Comments>
<Components>
<Component>
<Name>CsMpvCalcMatQtyHedgeBase.xpo</Name>
<Type>Classes</Type>
<Action>Edit</Action>
<Models>
<Model Id="I4C" Layer="ISV" />
</Models>
</Component>
<Component>
<Name>CsMpvInsertMatQtyDetails_Agreement.xpo</Name>
<Type>Classes</Type>
<Action>Edit</Action>
<Models>
<Model Id="I4C" Layer="ISV" />
</Models>
</Component>
<Component>
<Name>Cs2215_Mpv_HedgeQtyLookupPerformance.xpo</Name>
<Type>Shared</Type>
<Action>Add</Action>
<Models />
</Component>
</Components>
</ChangeSet>
</ChangeSets>
</ReleaseNotes>
要找到属性值,请提前谢谢..
答案 0 :(得分:1)
你几乎就在那里:
ReleaseNotes/ChangeSets/ChangeSet[Comments/checkintext/task/id[text()='CS-2215']]
(注意:我使用an online XPath fiddle tool来查找此内容。)
答案 1 :(得分:1)
这也应该有用。
//ChangeSet[.//id[text()='CS-2215']]
获取具有特定文本的子ID的所有变更集