我正在尝试创建一个XPath表达式,以便在MS InfoPath中使用,以便检索节点中最后一个兄弟的值。 (希望我能正确地表达这个问题,因为我几乎没有使用XPath)。
我需要识别“RepeaterGroup”节点内“NamesEval”节点的最新实例。假设我会看看“史蒂夫”是否参加了最新的活动;我将使用contains(LatestEvent, "Steve")
XPath表达式检查这一点。如何让“LatestEvent”仅加载最新的“NamesEval”值?
<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.2" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Chris\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer3\db543e141b8f4832\manifest.xsf" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-09-07T14:19:10" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
<my:InitialSection>
<my:InitialField>1</my:InitialField>
<my:InitialDate>2012-09-14</my:InitialDate>
</my:InitialSection>
<my:RepeaterSection>
<my:RepeaterGroup>
<my:RepeaterField>2</my:RepeaterField>
<my:RepeaterDate>2012-09-15</my:RepeaterDate>
<my:NamesGroup>
<my:NamesRepeater>
<my:Name>Steve</my:Name>
</my:NamesRepeater>
<my:NamesRepeater>
<my:Name>Ashley</my:Name>
</my:NamesRepeater>
<my:NamesRepeater>
<my:Name>Josh</my:Name>
</my:NamesRepeater>
</my:NamesGroup>
<my:NamesEval>Steve;Ashley;Josh;</my:NamesEval>
</my:RepeaterGroup>
<my:RepeaterGroup>
<my:RepeaterField>3</my:RepeaterField>
<my:RepeaterDate>2012-09-16</my:RepeaterDate>
<my:NamesGroup>
<my:NamesRepeater>
<my:Name>Amanda</my:Name>
</my:NamesRepeater>
<my:NamesRepeater>
<my:Name>Greg</my:Name>
</my:NamesRepeater>
<my:NamesRepeater>
<my:Name>Steve</my:Name>
</my:NamesRepeater>
</my:NamesGroup>
<my:NamesEval>Amanda;Greg;Steve;</my:NamesEval>
</my:RepeaterGroup>
</my:RepeaterSection>
编辑&amp; ANSWER
Choroba回答了以下问题 - 这是解决方案://my:RepeaterGroup[0=count(following-sibling::my:RepeaterGroup)]//my:NamesEval
答案 0 :(得分:4)
我不确定我理解你的问题。如果您要验证最后一个NamesEval是否包含字符串&#34; Steve&#34;,您可以使用以下XPath表达式:
contains((//my:NamesEval)[last()],'Steve')