title: Obtain value from XML element using XML parser and assign it to a variable
body: <p>I have the following XML:</p>
  
  <pre><code>        &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
               xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
          &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
          &lt;groupId&gt;BundleResourceDeploy&lt;/groupId&gt;
          &lt;artifactId&gt;Project3&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
          &lt;packaging&gt;sbar&lt;/packaging&gt;
          &lt;description&gt;&lt;/description&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Also I have the following XSLT stylesheet:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://maven.apache.org/POM/4.0.0" exclude-result-prefixes="ns"&gt;
  
   &lt;xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/&gt;
   &lt;xsl:template match="ns:project"&gt;
  
  
    &lt;xsl:element name="ns:groupId"&gt;
      &lt;xsl:value-of select="ns:groupId"/&gt;
    &lt;/xsl:element&gt;
  
    &lt;xsl:element name="ns:artifactId"&gt;
      &lt;xsl:value-of select="ns:artifactId"/&gt;
    &lt;/xsl:element&gt;
  
    &lt;xsl:element name="ns:version"&gt;
      &lt;xsl:value-of select="ns:version"/&gt;
    &lt;/xsl:element&gt;
  
    &lt;xsl:element name="ns:packaging"&gt;
      &lt;xsl:value-of select="ns:packaging"/&gt;
    &lt;/xsl:element&gt;
  
   &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Executing the command: xsltproc "stylesheet" "xml_file" > output.xml</p>
  
  <p>The output (content of output.xml file) is:</p>
  
  <pre><code>&lt;ns:groupId xmlns:ns="http://maven.apache.org/POM/4.0.0"&gt;BundleResourceDeploy&lt;/ns:groupId&gt;&lt;ns:artifactId xmlns:ns="http://maven.apache.org/POM/4.0.0"&gt;Project2&lt;/ns:artifactId&gt;&lt;ns:version xmlns:ns="http://maven.apache.org/POM/4.0.0"&gt;1.0-SNAPSHOT&lt;/ns:version&gt;&lt;ns:packaging xmlns:ns="http://maven.apache.org/POM/4.0.0"&gt;sbar&lt;/ns:packaging&gt;
  </code></pre>
  
  <p>What I want to achieve is:
  In a shell script I want to obtain the value of the element "groupId", which would be "BundleResourceDeploy", and assign it to a variable.</p>
  
  <p>Could you help me out with a way on how to achieve this? </p>