When I try to load on the dhtmlxgrid data with accents or special characters like & get an error “Incorrect XML”
To load the data I’m using dhtmlxconnector
Is there a way to solve this
Which component is used in problematic case?
Normally , connectors wraps all data in CDATA sections, so special chars can be processed without extra handling.
You can try to use beforeRender event to workaround the issue.
function my_escape($data){
$value = $data->get_value(“field_name”);
$value = str_replace("&","&",$value);
$data->set_value(“field_name”,$value);
}
$comp->event->attach(“beforeRender”,“my_escape”);
The problem happens with the Spanish accent (á, é, í, ó, ú)
The components used are dhtmlxgrid v.2.1 build 90226 and dhtmlxConnector for PHP v.0.9 build 90226
with the Spanish accent (á, é, í, ó, ú)
Which encoding you are using for data storage?
By default connector expect urf-8 usage, if you are using different encoding ( iso-8859-1 most probably ) you need to add the next line to the connector initialization code
$grid->set_encoding(“iso-8859-1”); //sets xml encoding
$grid->render_ …