title: Extract HTML elements with XSLT
body: <p>I would like to extract everything between the <code>&lt;head&gt;</code> tag elements in an html page. Including link tags and script tags. </p>
  
  <p>Assume the source code below is a snippet which would be part of a full html document.</p>
  
  <p>The source:</p>
  
  <pre><code>...
  &lt;head&gt;
   &lt;link rel="stylesheet" href="style.css"
      type="text/css" media="handheld" /&gt;
  
   &lt;link rel="stylesheet" href="style.css"
      type="text/css" media="handheld" /&gt;
  
   &lt;script type="text/javascript" src="main.js"&gt;&lt;/script&gt;
   &lt;script type="text/javascript" src="second.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  ...
  </code></pre>
  
  <p>XSLT:
      </p>
  
  <pre><code>&lt;xsl:output method="xml" encoding="utf-8" indent="no"/&gt;
  
  &lt;xsl:template match="/"&gt;
      &lt;xsl:copy-of select="link"/&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p></p>
  
  <p>This works fine if there is only one tag I'm trying to get. Is there a way I can process everything and only everything between the "head" tags.</p>
  
  <p>The output I expect would be:</p>
  
  <pre><code> &lt;link rel="stylesheet" href="style.css"
      type="text/css" media="handheld" /&gt;
  
   &lt;link rel="stylesheet" href="style.css"
      type="text/css" media="handheld" /&gt;
  
   &lt;script type="text/javascript" src="main.js"&gt;&lt;/script&gt;
   &lt;script type="text/javascript" src="second.js"&gt;&lt;/script&gt;
  </code></pre>