title: Jqgrid doesn't load XML data
body: <p>I'm trying to use JqGrid without sucess. I've read <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:first_grid" rel="nofollow">this wiki post at trirand</a> and I do exactly all the steps on that page.</p>
  
  <p>I've tried using other exaples that I've searched but I keep having the same error. I really don't why and it's very frustating.</p>
  
  <p>When I view the HTML, the table (mysql) doesn't show. It's like my code doesn't accept the XML data from the PHP code. I'm ussing Appserv. </p>
  
  <p>HTML code (<em>myfirstgrid.html</em>):</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
          &lt;title&gt;My First Grid&lt;/title&gt;
          &lt;link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.2.custom.css" /&gt;
          &lt;link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" /&gt;
  
          &lt;style type="text/css"&gt;
              html, body {
                  margin: 0;
                  padding: 0;
                  font-size: 75%;
              }
          &lt;/style&gt;
  
          &lt;script src="/jquery-1.7.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;script src="/i18n/grid.locale-en.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;script src="/jquery.jqGrid.min.js" type="text/javascript"&gt;&lt;/script&gt;
  
          &lt;script type="text/javascript"&gt;
          $(function(){ 
              $("#list").jqGrid({
                  url:'example.php',
                  datatype: 'xml',
                  mtype: 'GET',
                  colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
                  colModel :[ 
                      {name:'invid', index:'invid', width:55}, 
                      {name:'invdate', index:'invdate', width:90}, 
                      {name:'amount', index:'amount', width:80, align:'right'}, 
                      {name:'tax', index:'tax', width:80, align:'right'}, 
                      {name:'total', index:'total', width:80, align:'right'}, 
                      {name:'note', index:'note', width:150, sortable:false} 
                  ],
                  pager: '#pager',
                  rowNum:10,
                  rowList:[10,20,30],
                  sortname: 'invid',
                  sortorder: 'desc',
                  viewrecords: true,
                  gridview: true,
                  caption: 'My first grid'
              }); 
          }); 
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;table id="list"&gt;&lt;tr&gt;&lt;td/&gt;&lt;/tr&gt;&lt;/table&gt; 
          &lt;div id="pager"&gt;&lt;/div&gt; 
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP script (<em>example.php</em>):</p>
  
  <pre><code>&lt;?php 
      include ("conexion.php");
  
      $page = 1;
      $limit = 10;
      $sidx = 'tax';
      $sord = 'asc';
  
      $result = mysql_query("SELECT COUNT(*) AS count FROM invheader"); 
      $row = mysql_fetch_array($result,MYSQL_ASSOC); 
      $count = $row['count']; 
  
      if( $count &gt; 0 &amp;&amp; $limit &gt; 0) { 
          $total_pages = ceil($count/$limit); 
      } else { 
          $total_pages = 0; 
      }
  
      if ($page &gt; $total_pages) $page=$total_pages;
  
      $start = $limit*$page - $limit;
  
      // if for some reasons start position is negative set it to 0 
      // typical case is that the user type 0 for the requested page 
      if($start &lt;0) $start = 0; 
  
      // the actual query for the grid data 
      $SQL = "SELECT invid, invdate, amount, tax,total, note FROM invheader ORDER BY    $sidx $sord LIMIT $start , $limit"; 
      $result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error()); 
  
      // we should set the appropriate header information. Do not forget this.
      //header("Content-type: text/xml;charset=utf-8");
  
      $s = "&lt;?xml version='1.0' encoding='utf-8'?&gt;";
      $s .=  "&lt;rows&gt;";
      $s .= "&lt;page&gt;".$page."&lt;/page&gt;";
      $s .= "&lt;total&gt;".$total_pages."&lt;/total&gt;";
      $s .= "&lt;records&gt;".$count."&lt;/records&gt;";
  
      // be sure to put text data in CDATA
      while($row = mysql_fetch_array($result,MYSQL_ASSOC))
      {
          $s .= "&lt;row id='". $row['invid']."'&gt;";
          $s .= "&lt;cell&gt;". $row['invid']."&lt;/cell&gt;";
          $s .= "&lt;cell&gt;". $row['invdate']."&lt;/cell&gt;";
          $s .= "&lt;cell&gt;". $row['amount']."&lt;/cell&gt;";
          $s .= "&lt;cell&gt;". $row['tax']."&lt;/cell&gt;";
          $s .= "&lt;cell&gt;". $row['total']."&lt;/cell&gt;";
          $s .= "&lt;cell&gt;&lt;![CDATA[". $row['note']."]]&gt;&lt;/cell&gt;";
          $s .= "&lt;/row&gt;";
      }
      $s .= "&lt;/rows&gt;";
  
      echo $s;
  ?&gt;
  </code></pre>
  
  <p>This is the XML result that comes from th PHP script (the XML was indented for readability purposes. The server returns the xml without line breaks):</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;rows&gt;
      &lt;page&gt;1&lt;/page&gt;
      &lt;total&gt;1&lt;/total&gt;
      &lt;records&gt;3&lt;/records&gt;
      &lt;row id='1'&gt;
          &lt;cell&gt;1&lt;/cell&gt;
          &lt;cell&gt;0000-00-00&lt;/cell&gt;
          &lt;cell&gt;0.00&lt;/cell&gt;
          &lt;cell&gt;0.00&lt;/cell&gt;
          &lt;cell&gt;0.00&lt;/cell&gt;
          &lt;cell&gt;&lt;![CDATA[note]]&gt;&lt;/cell&gt;
      &lt;/row&gt;
      &lt;row id='2'&gt;
          &lt;cell&gt;2&lt;/cell&gt;
          &lt;cell&gt;2001-01-10&lt;/cell&gt;
          &lt;cell&gt;103.00&lt;/cell&gt;
          &lt;cell&gt;45.00&lt;/cell&gt;
          &lt;cell&gt;149.00&lt;/cell&gt;
          &lt;cell&gt;&lt;![CDATA[This is record 1]]&gt;&lt;/cell&gt;
      &lt;/row&gt;
      &lt;row id='3'&gt;
          &lt;cell&gt;3&lt;/cell&gt;
          &lt;cell&gt;2001-02-10&lt;/cell&gt;
          &lt;cell&gt;104.00&lt;/cell&gt;
          &lt;cell&gt;46.00&lt;/cell&gt;
          &lt;cell&gt;151.00&lt;/cell&gt;
          &lt;cell&gt;&lt;! [CDATA[This is record 2]]&gt;&lt;/cell&gt;
      &lt;/row&gt;
  &lt;/rows&gt;
  </code></pre>
  
  <p>These are my questions:</p>
  
  <ol>
  <li>Why the isn't my data shown in the HTML?</li>
  <li>If the problem is the XML data, what is the best way to check if the XML is valid or not?</li>
  </ol>