0

我正在尝试使用 xslt 访问每个节点的属性。但它没有用。需要为每个旅馆房间打印 shru 值。有人可以帮我吗???我

以下是我的 XML 响应。

   <HotelRoom SHRUI="AqZE8Cw72fDfNL6X0hqQTQ==" availCount="10" onRequest="N">
              <Board type="SIMPLE" code="BB-E10" shortname="BB">BED AND BREAKFAST</Board>
              <RoomType type="SIMPLE" code="SGL-E10" characteristic="ST">SINGLE STANDARD</RoomType>
              <Price>
                <Amount>549.360</Amount>
              </Price>
            </HotelRoom>

下面是我的 XSLT。

  <xsl:for-each select="hm:HotelRoom ">
                <shrui>
                  <xsl:value-of select="hm:HotelRoom/@SHRUI"/>
                </shrui>
                <board>
                  <xsl:value-of select="hm:Board"/>
                </board>
                <roomtype>
                  <xsl:value-of select="hm:RoomType"/>
                </roomtype>
                <roomcode>
                  <xsl:value-of select="hm:RoomType/@code"/>
                </roomcode>
                <boardcode>
                  <xsl:value-of select="hm:Board/@code"/>
                </boardcode>
                <xsl:for-each select="hm:Price ">
                  <amount>
                    <xsl:value-of select="hm:Amount"/>
                  </amount>
                </xsl:for-each>
              </xsl:for-each>
4

1 回答 1

1

代替...

<xsl:value-of select="hm:HotelRoom/@SHRUI"/>

...和...

<xsl:value-of select="@SHRUI"/>

此外,从外观上看,您可以从更具推动力的设计风格中受益(参考:http ://www.eddiewelker.com/2008/11/25/push-style-xslt-vs-pull-style/和http://www.ibm.com/developerworks/library/x-xdpshpul.html

于 2013-07-29T08:27:43.767 回答