title: How to pass environment variable to a command passed to xmllint?
body: <p>I'm trying to extract the <code>db</code> element's <code>value</code> attributes from an xml file using <code>xmllint</code></p>
  
  <p>My XPath Query needs to navigate to the correct dbtype, which I wish to store in an environment variable </p>
  
  <p>Without an environment variable (hard coded), this command works</p>
  
  <pre><code>echo 'cat //rdbmsinfo/dbtype[@value="sqlserver"]/db/@value' | xmllint --shell "config.xml" | grep -v "&gt;" | cut -f 2 -d "=" | tr -d \ | sed 's/"//g'
  </code></pre>
  
  <p>I am trying with below command:</p>
  
  <pre><code>echo 'cat //rdbmsinfo/dbtype[@value="$ldb_source_typ"]/db/@value' | xmllint --shell "config.xml" | grep -v "&gt;" | cut -f 2 -d "=" | tr -d \ | sed 's/"//g'
  </code></pre>
  
  <p>where <code>ldb_source_typ</code> is a variable to get the value from shell parameter as <code>"sqlserver"</code>. But the above syntax is not giving any output. </p>
  
  <p>Why isn't this working, and how can I fix it?</p>
  
  <p>My config.xml XML looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;rdbmsinfo&gt;
    &lt;dbtype value="sqlserver"&gt;
      &lt;db value="sqlsrv1"&gt;
        &lt;dbhostip&gt;192.168.0.1&lt;/dbhostip&gt;
        &lt;dbhostportno&gt;2000&lt;/dbhostportno&gt;
        &lt;dbusername&gt;sample&lt;/dbusername&gt;
        &lt;dbpassword&gt;sample&lt;/dbpassword&gt;
      &lt;/db&gt;
      &lt;db value="sqlsrv2"&gt;
        &lt;dbhostip&gt;192.168.0.2&lt;/dbhostip&gt;
        &lt;dbhostportno&gt;2000&lt;/dbhostportno&gt;
        &lt;dbusername&gt;sample&lt;/dbusername&gt;
        &lt;dbpassword&gt;sample&lt;/dbpassword&gt;
      &lt;/db&gt;
    &lt;/dbtype&gt;
    &lt;dbtype value="postgresql"&gt;
      &lt;db value="postsql1"&gt;
      &lt;/db&gt;
    &lt;/dbtype&gt;
  &lt;/rdbmsinfo&gt;
  </code></pre>