title: XSLT If condition Help
body: <p>I have an XML and XSLT. I want to use the if condition to check if an element is 0, if it is then hide it i.e display nothing. IF 0 is found, simply display a blank cell.</p>
  
  <p>Here is the basic concept:</p>
  
  <p>XML</p>
  
  <pre><code> &lt;Sheet1&gt;
       &lt;Build&gt;0&lt;/Build&gt;
       &lt;Item&gt;X&lt;/Item&gt;
       &lt;T1&gt;0:06:00&lt;/T1&gt;
       &lt;T2&gt;0:14:15&lt;/T2&gt;
       &lt;T3&gt;0:07:22&lt;/T3&gt;
   &lt;/Sheet1&gt;
  </code></pre>
  
  <p>XSLT</p>
  
  <pre><code>&lt;table border="1"&gt;
      &lt;tr bgcolor="#dccdc"&gt;
          &lt;th align="center"&gt;Build&lt;/th&gt;
          &lt;th align="center"&gt;Item&lt;/th&gt;
          &lt;th align="center"&gt;T1&lt;/th&gt;
          &lt;th align="center"&gt;T2&lt;/th&gt;
          &lt;th align="center"&gt;T3&lt;/th&gt;
      &lt;/tr&gt;  
  
      &lt;xsl:for-each select="Sheet1"&gt;
          &lt;tr&gt;
              &lt;td bgcolor="#F2F5A9"&gt;
                  &lt;xsl:value-of select="Build" /&gt;
              &lt;/td&gt;
              &lt;td bgcolor="#F2F5A9"&gt;
                  &lt;xsl:value-of select="Item" /&gt;
              &lt;/td&gt;
              &lt;td bgcolor="#F2F5A9"&gt;
                  &lt;xsl:value-of select="T1" /&gt;
              &lt;/td&gt;
              &lt;td bgcolor="#F2F5A9"&gt;
                  &lt;xsl:value-of select="T2" /&gt;
              &lt;/td&gt;
              &lt;td bgcolor="#F2F5A9"&gt;
                  &lt;xsl:value-of select="T3" /&gt;
              &lt;/td&gt;
           &lt;/tr&gt;
       &lt;/xsl:for-each&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>What I want to do is when Build element = 0 i want it to print nothing, so i tried putting an xsl:if around the item in the XSLT:</p>
  
  <pre><code>&lt;xsl:if test="Build!='0'"&gt;
      &lt;td bgcolor="#F2F5A9"&gt;
          &lt;xsl:value-of select="Build" /&gt;
      &lt;/td&gt;
  &lt;/xsl:if&gt;
  </code></pre>
  
  <p>but this does not seem to work, i get a blank output file.</p>
  
  <p>any ideas?</p>