title: How to loop through elements in an xml document using XSLT
body: <p>I am using XSLT to loop through an XML document.
  <br>The root node of the document is called <b>movies</b> and it can contain one or more <b>movie</b> elements. However these <b>movie</b> elements contain single elements except for the <b>actor</b> element. How can you loop through to display more than one actor? I am already using <code>&lt;xsl:for-each&gt;</code> to loop throught each <b>movie</b>.<br>
  Here is the xslt:<br><br></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
  
  &lt;xsl:template match="/movies"&gt;
  
  &lt;html&gt;
      &lt;head&gt;
      &lt;link rel="stylesheet" href="stylecss.css" /&gt;
          &lt;title&gt;My Movies Collection&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;!-- Use for each loop to extract all child nodes and their information--&gt;
  
      &lt;xsl:for-each select="/movies/movie"&gt;
      &lt;!--Add title as well as year--&gt;
          &lt;h1&gt;&lt;xsl:value-of select="title" /&gt;
          &lt;xsl:text&gt; ( &lt;/xsl:text&gt;
          &lt;xsl:value-of select="@year" /&gt;
          &lt;xsl:text&gt; ) &lt;/xsl:text&gt;
  
          &lt;/h1&gt;
          &lt;p&gt;
          &lt;img&gt;
              &lt;xsl:attribute name="src"&gt;
              &lt;xsl:value-of select="poster" /&gt;
              &lt;/xsl:attribute&gt;
          &lt;/img&gt;
          &lt;span id="details"&gt;
  
          &lt;xsl:text&gt;Review: &lt;/xsl:text&gt;
          &lt;xsl:value-of select="@review" /&gt;
          &lt;xsl:text&gt;, Type: &lt;/xsl:text&gt;
          &lt;xsl:value-of select="@type" /&gt;
          &lt;br&gt;&lt;/br&gt;
  
          &lt;xsl:text&gt;Producer: &lt;/xsl:text&gt;
          &lt;xsl:value-of select="producer" /&gt; 
          &lt;br/&gt;
  
          &lt;xsl:text&gt;Actor: &lt;/xsl:text&gt;
          &lt;xsl:value-of select="actor"/&gt; &lt;br/&gt;
  
          &lt;xsl:text&gt;Director: &lt;/xsl:text&gt;
          &lt;xsl:value-of select="director" /&gt;&lt;br/&gt;
          &lt;br/&gt;
  
  
  &lt;i&gt;         &lt;xsl:text&gt;Comments: &lt;/xsl:text&gt;
          &lt;xsl:value-of select="comments" /&gt; &lt;/i&gt;
  
  
  
          &lt;/span&gt;
          &lt;/p&gt;
  
      &lt;/xsl:for-each&gt;
  
      &lt;/body&gt;
  
  &lt;/html&gt;
  
  
  
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p><br><br>
  The xml document itself:<br><br></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?xml-stylesheet type="text/xsl" href="stylesheet.xslt" ?&gt;
  &lt;movies&gt;
    &lt;movie type="comedy" rating="PG" review="4" year="1997"&gt;
    &lt;title&gt;How To Be A Player&lt;/title&gt;
    &lt;writer&gt;Mark Brown&lt;/writer&gt;
    &lt;producer&gt;Todd R. Baker&lt;/producer&gt;
    &lt;director&gt;Russell Simmons&lt;/director&gt;
    &lt;actor&gt;Bill Bellamy&lt;/actor&gt;
    &lt;actor&gt;Mari Morrow&lt;/actor&gt;
    &lt;poster&gt;img/htbap.jpeg&lt;/poster&gt;
    &lt;comments&gt;Promotes polygamy&lt;/comments&gt;  
    &lt;/movie&gt;
  
  
    &lt;movie type="comedy" rating="PG" review="5" year="2010"&gt;
    &lt;title&gt;Grown Ups&lt;/title&gt;
    &lt;writer&gt;Adam Sandler&lt;/writer&gt;
    &lt;producer&gt;Jack Giarraputo&lt;/producer&gt;
    &lt;director&gt;Fred Wolf&lt;/director&gt;
    &lt;actor&gt;Chris Rock&lt;/actor&gt;
    &lt;actor&gt;Rob Schneider&lt;/actor&gt;
    &lt;poster&gt;img/gu.jpeg&lt;/poster&gt;
    &lt;comments&gt;Funny stuff&lt;/comments&gt;  
    &lt;/movie&gt;
  
   &lt;movie type="drama" rating="PG" review="5" year="2010"&gt;
    &lt;title&gt;The Social Network&lt;/title&gt;
    &lt;writer&gt;Dana Brunetti&lt;/writer&gt;
    &lt;producer&gt;Scott Rudin&lt;/producer&gt;
    &lt;director&gt;David Fincher&lt;/director&gt;
    &lt;actor&gt;Jesse Eisenberg&lt;/actor&gt;
    &lt;actor&gt;Justin Timberlake&lt;/actor&gt;
    &lt;poster&gt;img/sn.jpeg&lt;/poster&gt;
    &lt;comments&gt;So innovative&lt;/comments&gt;  
    &lt;/movie&gt;
  
    &lt;movie type="comedy" rating="PG" review="5" year="2012"&gt;
          &lt;title&gt;Project X&lt;/title&gt;
          &lt;writer&gt;Nima Nourizadeh&lt;/writer&gt;
          &lt;producer&gt;Todd Phillips&lt;/producer&gt;
          &lt;director&gt;Nima Nourizadeh&lt;/director&gt;
          &lt;actor&gt;Thomas Mann&lt;/actor&gt;
          &lt;actor&gt;Oliver Cooper&lt;/actor&gt;
          &lt;poster&gt;img/px.jpeg&lt;/poster&gt;
          &lt;comments&gt;Best party to ever&lt;/comments&gt;
      &lt;/movie&gt; 
  
  &lt;/movies&gt;
  </code></pre>