title: How to search a tag value of XML file in Unix?
body: <p>I have an xml like below</p>
  
  
  
  <pre><code>&lt;productCode&gt;
      &lt;codingScheme&gt;BDR&lt;/codingScheme&gt;
  &lt;/productCode&gt;
  &lt;productCode&gt;
      &lt;codingScheme&gt;CNY&lt;/codingScheme&gt;
  &lt;/productCode&gt;
  ...
  &lt;riskCategoryCode&gt;
      &lt;codingScheme&gt;BDR&lt;/codingScheme&gt;
  &lt;/riskCategoryCode&gt;
  &lt;riskCategoryCode&gt;
      &lt;codingScheme&gt;NCP&lt;/codingScheme&gt;
  &lt;/riskCategoryCode&gt;
  ...
  </code></pre>
  
  <p>Now I need to count how many such <em>BDR</em> values are there for <code>codingScheme</code> under <code>productCode</code> tag only.</p>
  
  <p>I wrote this script:</p>
  
  
  
  <pre><code>Word1="&lt;productCode&gt;";
  Word2="&lt;codingScheme&gt;BDR";
  Word3="$Word1${Var}$Word2";
  echo "$Word3";
  grep -c "$Word3" fileFullName;
  </code></pre>
  
  <p>But it counts the total occurences of <code>productCode</code> and <code>codingScheme</code> (eg. <code>productCode</code> 10 times and <code>codingScheme</code> 20 times then it returns 30 which is not required).</p>