How can I get value of repeated attribute?

89 Views Asked by At
<?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>

How can I get the value of meta? I try to use

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

It does not work.

1

There are 1 best solutions below

0
On

You have not properly described the question your asking but im assuming you want all meta direction values to get printed.

<?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>

output will be something like this,

  original
  reply
  independent

you have got the path of your value of select wrong.