我在php中创建xml文件时遇到了这个错误。 cna你能告诉我解决方案
error on line 7 at column 374: xmlParseEntityRef: no name
header("Content-Type: application/xml; charset=utf-8");
date_default_timezone_set("Asia/Calcutta");
$content=$this->view->data=$this->CallModel('posts')->GalleryAndContent();
$xml = '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>';
$xml.='<title>Thehansindia</title>
<link>http://www.thehansindia.com</link>
<description>Newspaper with a difference</description>';
foreach($content as $k){
$data=strip_tags(stripslashes($k['text_data']),"<p><span><div>");
$data=preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $data);
$data=str_replace(array("<div>","</div>","<span>","</span>"),array("<p>","</p>","<p>","</p>"),$data);
$data= preg_replace('/<p>\p{Z}*<\/p>/u', '', $data);
$data=str_replace("<p/>"," ",$data);
$data= preg_replace('/<p>\p{Z}*<\/p>/u', '', $data);
$data=str_replace( '<p> </p>', ' ', $data);
$data=str_replace( ' ', ' ', $data);
// $pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";
// $data= preg_replace($pattern, '', $data);
/
$xml.= '<item>';
$xml.=" <storyid>".$k['id']."</storyid>";
$xml.=" <Headline>".$k['title']."</Headline>";
//$xml.="<content>".html_entity_decode($data)."</content>";
$dom = new DOMDocument;
@$dom->loadHTML($data);
$xml.="<CONTENT>";
foreach ($dom->getElementsByTagName('p') as $tag){
if(!empty($tag->nodeValue)){
$xml.="<p>".$tag->nodeValue."</p>";
}
}
// $xml.="<CONTENT>".$VALUES['text_data']."</CONTENT>";
$xml.="</CONTENT>";
$xml.= '</item>';
}
$xml.='</channel></rss> ';
echo $xml;
这是我的代码。通过使用这个我在xml页面中显示mysql的内容。那个somany特殊的chrs就是那就是为什么我在那里使用了html_entity_decode。你能告诉我那个解决方案吗