October 22, 2016
Hot Topics:


  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

In my view, without XSL (XSL is basically like a stylesheet, except it has its own syntax) XML is not very practical. XSL allows you to extract the data of a tag and format it however you want.

Say you have an XML document that looks like this:

<person>    <name>Sam Huggill</name></person>

This is very simple, but with XSL you can extractthe value in-between the <name> and </name> tags and formatit. We extract the value of a tag using the <xsl:value-of> tag:


(Notice the closing />. This means that the tag does not need another </xsl:value-of> tag). Easy.

But what happens when we have a more complicated XML document:

 <people>    <person>        <name>Sam Huggill</name>        <email>sam@vbsquare.com</email>    </person>    <person>        <name>Yourname</name>        <email>youremail</email>    </person></people> 

For this we will have to set up a loop to write the data from both <person> tags. We loop using the <xsl:for-each> tag:

 <xsl:for-eachselect="people/person">    <xsl:value-of select="name"/>    <xsl:value-of select="email"/></xsl:for-each> 

Page 2 of 6

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel