·  XSLT – Elements – <xsl:element> <xsl:attribute>

 

- Info :

  - <xsl:element> is used to created an element.

  - <xsl:attribute> is used to add attribute. You can it's define name and value.

 

- Example:

 

    test.xml

    <?xml version="1.0"?>

    <?xml-stylesheet type="text/xsl" href="test.xsl"?>

    

    <people>

    

      <student>

        <name>Jack</name>

        <name>Anton</name>

      </student>

    

    </people>

    

    test.xsl

    <?xml version="1.0" ?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    

      <xsl:template match="/people/student/name">      

    

        <xsl:element     name  ="font">

          <xsl:attribute name  ="color">red</xsl:attribute>

          <xsl:value-of  select="."/>

        </xsl:element>

    

      </xsl:template>

      

    </xsl:stylesheet>

    

    result

    JackAnton