title: How to set the 'targets' dynamically in columnDefs dataTable.js
body: <p>I am generating the <code>dataTable</code> from <code>xml</code> data. I want to change the column visibility based upon the column name. I Do not want to hard code the value for <code>targets</code> like 2 or 3 and also I do not want to set based on the class name.</p>
  
  <pre><code>$(document).ready(function() {
     var dataOptions = {
      {
        "columnDefs": [ {
           "visible": false,
           "targets":2
       } ]
      }
  
     };
     $('#example').dataTable( dataOptions );
  } );
  
  #Edit
  My XML DATA
    &lt;root&gt;
      &lt;filterStartDate&gt;2006-11-18&lt;/filterStartDate&gt;
      &lt;filterEndDate&gt;2015-02-11&lt;/filterEndDate&gt;
      &lt;responseCount&gt;0&lt;/responseCount&gt;
      &lt;responseCountFormatted&gt;&lt;/responseCountFormatted&gt;
      &lt;metadata&gt;
       &lt;columns&gt;
          &lt;column name="startDate" type="DATE" nameT="Start Date" sortable="true" /&gt;
          &lt;column name="endDate" type="DATE" nameT="End Date" sortable="true" /&gt;
          &lt;column name="COMPANY_ID" type="STRING" nameT="Company" sortable="true" /&gt;
          &lt;column name="COMPANY_ID___code" type="STRING" nameT="Company" visible="false" /&gt;
          &lt;column name="multipleGroupBy" type="STRING" nameT="Multiple Group By" visible="false" /&gt;
       &lt;/columns&gt;
      &lt;/metadata&gt;
      &lt;pageInformation&gt;&lt;totalPages&gt;1&lt;/totalPages&gt;&lt;totalRows&gt;10&lt;/totalRows&gt;&lt;pageStart&gt;0&lt;/pageStart&gt;&lt;pageEnd&gt;10&lt;/pageEnd&gt;&lt;rowsPerPage&gt;50&lt;/rowsPerPage&gt;&lt;/pageInformation&gt;
      &lt;data&gt;
         &lt;row startDate="2006-11-18" endDate="2015-02-11" COMPANY_ID="CONSUMER" COMPANY_ID___code="CONSUMER" multipleGroupBy="|CONSUMER"&gt;
         &lt;/row&gt;
      &lt;/data&gt;
     &lt;/root&gt;
  </code></pre>
  
  <p>Can I achieve this in a better way...</p>