我需要调整以下 XPath 表达式以Amend_Start_Date
从示例 XML(来自 MS InfoPath)返回“最新”:
//my:Amend_Data[0=count(following-sibling::my:Amend_Data)]//my:Amend_Start_Date
和 XML:
<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.440" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Chris\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer3\1c02663d7ed84d09\manifest.xsf" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?><?mso-infoPath-file-attachment-present?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-05-05T19:56:08" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
<my:MasterSection>
<my:Planning_Section>
<my:Planned_Start_Date>2012-09-12</my:Planned_Start_Date>
<my:Planned_End_Date>2012-09-14</my:Planned_End_Date>
</my:Planning_Section>
<my:Actual_Section>
<my:Actual_Start_Date>2012-09-13</my:Actual_Start_Date>
<my:Actual_End_Date>2012-09-15</my:Actual_End_Date>
</my:Actual_Section>
<my:Amend_Hider>
<my:Amend_Info_Repeater_Group>
<my:Amend_Info_Repeater>
<my:Amend_Data>
<my:Amend_Start_Date>2012-09-16</my:Amend_Start_Date>
<my:Amend_End_Date>2012-09-21</my:Amend_End_Date>
</my:Amend_Data>
</my:Amend_Info_Repeater>
<my:Amend_Info_Repeater>
<my:Amend_Data>
<my:Amend_Start_Date>2012-09-23</my:Amend_Start_Date>
<my:Amend_End_Date>2012-09-27</my:Amend_End_Date>
</my:Amend_Data>
</my:Amend_Info_Repeater>
</my:Amend_Info_Repeater_Group>
</my:Amend_Hider>
</my:MasterSection>
我上周四开始使用 XPath ......如果我需要用勺子喂食,请原谅我。就目前而言,列出的表达式返回示例 XML 中的所有开始日期节点。它旨在返回“最新” Amend_Start_Date
,但不是因为 XML 的结构使得Amend_Start_Date
节点没有组合在一起。在这个例子中,这意味着一个正确的表达式将返回一个开始日期2012-09-23
而不是 2012-09-16
一定有办法做到这一点!必须以某种Amend_Data
方式修改节点的相对路径......感谢任何帮助!
PS:这与我周五发布的一个问题有关,可以在这里找到。您可能会注意到该问题与此问题中列出的示例 XML 的结构差异。