0

这是我的 xml 文件中的一个片段

     <uformrecord>
          <state>Submitted</state>
          <created>2012-06-19T11:31:54</created>
          <updated>2012-06-19T11:32:13</updated>
          <id>53225sas3c1-d727-42cd-93a6-97cd778e5ee9</id>
          <ip>123.45.3.60</ip>
          <pageid url="/blah.aspx" name="Vacancy Application">1873</pageid>
          <memberkey emaillogin=""></memberkey>
          <fields>

            <ifyouhavetickedyeshowwouldyoudescribeyourdisabilitytickallthatapplytoyou record="532253c1-d727-42cd-93a6-97cd778e5ee9" sortorder="1" pageindex="2" fieldsetindex="0">
              <key>73b9150d-c65c-4ec0-9c8f-8d334b0495bf</key>
              <fieldKey>07a8ade7-ae13-41e6-bc3a-fe8444bcf9b0</fieldKey>
              <caption>If you have ticked 'Yes', how would you describe your disability (Tick all that apply to you.)</caption>
              <datatype>String</datatype>
              <values>
                <value key="c6de1932-9bba-4691-b19e-a44b5bb68c6c">I have a hearing problem</value>
                <value key="dd902bdb-89d7-4f14-ab60-4e69e803f321">I use a wheelchair</value>
                <value key="322c8e15-f722-406c-9d10-1769a2fb306e">I am dyslexic</value>
              </values>
            </ifyouhavetickedyeshowwouldyoudescribeyourdisabilitytickallthatapplytoyou>

    <anotherfieldblaf record="532253c1-d727-42cd-93a6-97cd778e5ee9" sortorder="1" pageindex="1" fieldsetindex="0">
              <key>73b9150d-c65c-4ec0-9c8f-8d334b0495bf</key>
              <fieldKey>07a8ade7-ae13-41e6-bc3a-fe8444bcf9b0</fieldKey>
              <caption>If you have ticked 'Yes', how would you describe your disability (Tick all that apply to you.)</caption>
              <datatype>String</datatype>
              <values>
                <value key="c6de1932-9bba-4691-b19e-a44b5bb68c6c">I have a hearing problem</value>
                <value key="dd902bdb-89d7-4f14-ab60-4e69e803f321">I use a wheelchair</value>
                <value key="322c8e15-f722-406c-9d10-1769a2fb306e">I am dyslexic</value>
              </values>
            </anotherfieldblaf>
.
.
.
.//many more fields
          </fields>
        </uformrecord>

我使用这样的 xpath 来获取字段。

<xsl:for-each select="$records//fields/child::*">

这将返回所有字段,但是我只想获取该字段的 pageindex=2 的字段。

我该怎么做?谢谢

4

1 回答 1

2

你需要做的就是这个...

<xsl:for-each select="$records//fields/child::*[@pageindex='2']"> 
于 2012-09-04T14:47:28.810 回答