title: XSLT Formatting to remove empty columns (And the headers)
body: <p>I have a database field I am pulling xml out of. This field contains the content from multiple XML feeds of which I need two. I am displaying the XML on a page and using XSLT to format it.</p>
  
  <p>My issue is that there could be up to 40 elements per message in the DB, of that I am looking for about 30. However, not all messages will have all 30. I need help figuring out how to remove a column if there is no data to display.</p>
  
  <p>If I can use XSLT then great, if it is JavaScript(Jquery) then that is fine too. There will never be more then one row and one header at a time.</p>
  
  <p>Here is a sample of the XML</p>
  
  <pre><code>&lt;MessageToUser&gt;
    &lt;Name&gt;Bob&lt;/Name&gt; 
    &lt;MessageType&gt;Text Message&lt;/MessageType&gt; 
    &lt;MessageID&gt;121223&lt;/MessageID&gt;
    &lt;ResponseTo /&gt;
    &lt;Message&gt;Call Me Please &lt;/Message&gt; 
    &lt;OfficePhone&gt;555-555-1212&lt;/OfficePhone&gt;
    &lt;CellPhone&gt;555-555-5555&lt;/CellPhone&gt;
  &lt;/MessageToUser&gt;
  </code></pre>
  
  <p>And here is the XSL I am using</p>
  
  <pre><code>&lt;xsl:template match="/"&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;style type="text/css"&gt;
      .Header{min-width: 100px;background-color:#9acddd;}
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;table border="1"&gt;
      &lt;tr&gt;
          &lt;th class="Header"&gt;Name&lt;/th&gt;
          &lt;th class="Header"&gt;Message&lt;/th&gt;
          &lt;th class="Header"&gt;Cell Phone&lt;/th&gt;
          &lt;th class="Header"&gt;Office Phone&lt;/th&gt;
          &lt;th class="Header"&gt;Message Type&lt;/th&gt;
          &lt;th class="Header"&gt;Message Time&lt;/th&gt;
          &lt;th class="Header"&gt;Message ID&lt;/th&gt;
        &lt;/tr&gt;
        &lt;xsl:for-each select="MessageFromUser"&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;xsl:value-of select="Name" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="Message" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="CellPhone" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="OfficePhone" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="MessageType" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="MessageTime" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="MessageID" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/xsl:for-each&gt;
        &lt;xsl:for-each select="MessageToUser"&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;xsl:value-of select="Name" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="Message" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="CellPhone" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="OfficePhone" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="MessageType" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="MessageTime" /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;xsl:value-of select="MessageID" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/xsl:for-each&gt;
      &lt;/table&gt;
   &lt;/body&gt;
  </code></pre>
  
  <p>
  
   </p>
  
  <p>Using this XML MessageTime is blank and that column should be removed. </p>
  
  <p>Thanks in advance for any help.</p>