2

我正在尝试创建一个用于 MS InfoPath 的 XPath 表达式,以便检索节点中最后一个兄弟的值。(希望我正确地表达了这个问题,因为我几乎没有使用过 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>

编辑和回答

Choroba 回答了以下问题 - 这是解决方案://my:RepeaterGroup[0=count(following-sibling::my:RepeaterGroup)]//my:NamesEval

4

1 回答 1

5

我不确定我是否理解你的问题。如果您尝试验证最后一个 NamesEval 是否包含字符串“Steve”,则可以使用以下 XPath 表达式:

contains((//my:NamesEval)[last()],'Steve')
于 2012-09-07T18:14:24.053 回答