如何获得重复属性的值?

时间:2013-11-06 02:25:50

标签: xml xslt nodename

<?xml version="1.0" encoding="UTF-8"?>
<con>
   <ff>
      <meta direction="original">
         <layer3 protoname="ipv4" />
         <layer4 protoname="tcp" />
      </meta>
      <meta direction="reply">
         <layer3 protoname="ipv4" />
         <layer4 protoname="tcp" />
      </meta>
      `enter code here`
      <meta direction="independent" />
   </ff>
</con>

我怎样才能获得meta的价值? 我尝试使用

xsl:value-of select="meta/@direction"

它不起作用。

1 个答案:

答案 0 :(得分:0)

您没有正确描述您提出的问题,但我假设您希望打印所有meta direction值。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
   <xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes" />
   <xsl:template match="meta">
      <xsl:value-of select="@direction" />
   </xsl:template>
</xsl:stylesheet>

输出将是这样的,

  original
  reply
  independent

你有选择错误价值的路径。

相关问题