Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sirish on May 29, 2009 12:11
open dhtmlx forum
Dhtmx grid with Oracle and php

hello

below is the code for populating the email table to grid. but i am geting incorrect xml error. can anybody help me please

<?php

//include db connection settings
require_once '../adodbcon.php';


//print tree XML based on parent_id (function calls itself to go through the nested levels)
    function getRowsFromDB($parent_id){
        //get tree level from database taking parent id as incomming argument
        
        $sql = "SELECT email_id,recipient_id,status,status_cdtyp from email_recipients_hist";
        //echo $sql;
        $recordset = $conn->Execute($sql);
        
            while(!$recordset->EOF)
            {
                //create xml tag for grid row
                print("<row id='".$recordset->fields['email_id']."'>");
                print("<cell><![CDATA[".$recordset->fields['recipient_id']."]]></cell>");
                print("<cell><![CDATA[".$recordset->fields['status']."]]></cell>");
                print("<cell><![CDATA[".$recordset->fields['status_cdtyp']."]]></cell>");
                //close xml tag for the row
                print("</row>");
            }
        //$mon = 0;
    }

//XML HEADER

//include XML Header (as response will be in xml format)
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
        header("Content-type: application/xhtml+xml"); } else {
        header("Content-type: text/xml");
}
echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
?>
<!-- start grid xml -->
<rows id="0">
    
<?php
    //print tree XML
    getRowsFromDB(0);
    //Close db connection
    //mysql_close($link);
?>

<!-- close grid xml -->
</rows>
Answer posted by dhxSupport on Jun 01, 2009 01:47
Reasons of "Incorrect XML" erro could be:
1) XML data is invalid ( invalid structure of XML ); 
      if some kind of server side error occurs, error or debug output may break valid xml data;
2) invalid content type ( must be a text/xml for XML data );
3) whitespaces before <?xml output;
4) not escaped special characters, such as &, <, >; 
5) incorrect encoding of data.

Solution: 
1) use debug version of dhtmlxcommon.js , which will show extended error info;
2) load the same URL in separate browser window - it will show reason and location of error;
3) correctly escape special characters in XML data.