In the file views_xml.module

function views_xml_strip_illegal_chars($input) {
  $output = str_replace('>', '&rt;', $output); //encode right-angled bracket

Please replace it to:

  $output = str_replace('>', '&qt;', $output); //encode right-angled bracket
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pvasili’s picture

hm... next

...
  $output = str_replace('"', '"', $output); //encode quote
  $output = str_replace('&', '&', $output); //encode ampersand
...

input: "
output: &аmp;quot;

:(

I think better use htmlspecialchars ()

andypost’s picture

Status: Needs review » Fixed

Fixed in 6-dev

sher1’s picture

Category: bug » task
Priority: Critical » Minor

I found a site http://www.sourcerally.net/Scripts/39-Convert-HTML-Entities-to-XML-Entities
that showed how to convert html entities to xml safe ones.

Here is a code snippet of what I did to my custom view - in case it helps someone else and also to consider in replacing the views_xml_strip_illegal_chars function:

function xml_raw_render($view) {
	$xmlEntities = array('"','&','&','<','>',' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ');
	$htmlEntities = array('"','&','&','<','>',' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ');


	$xml .= '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
	$xml .= '<!-- generator="Drupal Views_Datasource.Module" -->'."\n";
	$xml .='<nodes>'."\n";  
  
  foreach ($view->result as $node) {
    $xml .= '  <node>'."\n";   
    foreach($node as $label => $value) {
      if (is_null($value) || ($value === '')) continue;
      $label = str_replace('_value', '', str_replace("profile_values_profile_", '', $label)); //strip out Profile: from profile fields
      $label = str_replace('_value', '', str_replace("node_data_field_feature_image_field_feature_", '', $label)); //strip out node_data_field_feature_image_field_feature from labels
      if ((strtolower($label) == 'text') || (strtolower($label) == 'node_revisions_body'))
        $label = "text";
	    //added code to replace html entities with xml safe entities
		$value = str_replace($htmlEntities,$xmlEntities,$value);
		$value = str_ireplace($htmlEntities,$xmlEntities,$value);
sher1’s picture

I added the attached file since the code get's truncated in the view

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.