Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Xslt Value Of in XML

Xslt Value Of in XML

? Using <xsl:value-of> in XSLT (XML)


<xsl:value-of> is used to extract and output the string value of an XML node or expression during an XSLT transformation.


Basic Syntax

<xsl:value-of select="XPath-expression"/>
  • The select attribute contains an XPath expression pointing to the node or value you want.

  • It outputs the text content of the selected node.


Example

Input XML

<person>  <name>John Doe</name>  <age>30</age></person>

XSLT using <xsl:value-of>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    <xsl:template match="/person">    <div>      Name: <xsl:value-of select="name"/><br/>      Age: <xsl:value-of select="age"/>    </div>  </xsl:template></xsl:stylesheet>

Output

<div>  Name: John Doe<br/>  Age: 30</div>

Notes

  • Outputs only the first node’s string value if the XPath matches multiple nodes.

  • To output multiple nodes, use it inside <xsl:for-each> or multiple templates.

  • For raw XML output, use <xsl:copy-of> instead.


Want an example showing how to use <xsl:value-of> with expressions or concatenation?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql