Get value out of two tags : value of « XSLT stylesheet « XML






Get value out of two tags

File: Data.xml

<?xml version="1.0" encoding="utf-8"?>
<emailList>
  <person>
    <name>person1</name>
    <email>p@hotmail.com</email>
  </person>
  <person>
    <name>person2</name>
    <email>p@hotmail.com</email>
  </person>
  <person>
    <name>person3</name>
    <email>p3@hotmail.com</email>
  </person>
</emailList>


File: Transform.xslt

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
          version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
  <xsl:template match="/emailList/person">
    <xsl:value-of select="name"/>,<xsl:value-of select="email"/>
  </xsl:template>
</xsl:stylesheet>

Output:


  person1,p@hotmail.com
  person2,p@hotmail.com
  person3,p3@hotmail.com

 








Related examples in the same category

1.Get value of element
2.Get value of element with @
3.Use value-of to get the size of text
4.Get value from element and attribute
5.select="child::name/following-sibling::*"
6.value-of select="$sortedCities" separator=" "