使用XPath定位XML的一部分[重复]

重复   请问每个人每次只重复一次文本吗? 我有使用XPATH指向XML中的某些元素的问题。 这是我的XML代码:            
    <character>
      <name>some name </some name>
    </character>

  </quote>
 <quote>
  ....
  </quote>
 </quotes>
这里是我的XSLT代码:
<xsl:for-each select="quotes/quote">
    <xsl:value-of select="quotes/quote/character/name"/>
 </xsl:for-each>
我尝试做的是我尝试列出每个引号的字符名称。 BUt这段代码不起作用 请问你帮我解决这个问题吗?谢谢     
已邀请:
for-each
中,上下文节点是
quote
- 所以看起来你只需要:
<xsl:for-each select="quotes/quote">
    <xsl:value-of select="character/name"/>
</xsl:for-each>
当然,纯粹主义者会争辩说使用
match
会更好:
<xsl:apply-templates select="quotes/quote" />
...
<xsl:template match="quote">
    <xsl:value-of select="character/name"/>
</xsl:template>
    
错误是: 你使用报价/报价两次 你可以尝试这个:
<xsl:for-each select="quotes/quote">
  <xsl:value-of select="character/name"/>
</xsl:for-each>
    

要回复问题请先登录注册