如何使用php在xml文件中提供换行符?

如何使用php在xml文件中提供换行符?,php,xml,Php,Xml,我正在使用php在xml文件中显示mysql数据 我在这里用了这个,我想给换行符。如果我们给换行符,就会在内容中显示换行符标记。我们必须给html标记。但是我们不在xml内容中显示它们 输出是这样的 同时,我想删除空的p标签也…就是说 <![CDATA[ <p> </p>]]> ]> 这是我为xml编写的代码 请解决这个问题 标题(“内容类型:application/xml;字符集=utf-8”); 日期默认时区设置(“亚洲/加尔各答”); $this->

我正在使用php在xml文件中显示mysql数据

我在这里用了这个,我想给换行符。如果我们给换行符,就会在内容中显示换行符标记。我们必须给html标记。但是我们不在xml内容中显示它们

输出是这样的

同时,我想删除空的p标签也…就是说

<![CDATA[ <p> </p>]]>

]>
这是我为xml编写的代码

请解决这个问题 标题(“内容类型:application/xml;字符集=utf-8”); 日期默认时区设置(“亚洲/加尔各答”); $this->view->data=$this->CallModel('posts')->GalleryAndContent(); $xml='0 ';
$xml.='Thehansindia “与众不同的报纸”; foreach($this->view->data as$values) {
$output=strip_标记($value['text_data'],“”); $output=preg_replace('/(]+)style=“.?”/i'、'$1'、$output); $output=preg_replace('/(]+)class=“.?”/i'、'$1'、$output); $output=preg\u replace('/style=([“\'])[^\1]?\1/i',''$output,-1); $output=preg_replace(“/]*?(/?)>/i”,”,“$output); $output=str_replace(数组(“,”),数组(“”,“

”),$output); $output=str_replace(数组(“,”)、数组(“”、“

”)、$output)

/$xml.=''
$xml.='';
$dom=新的DOMDocument;
@$dom->loadHTML($output);
$xml.=“”;
foreach($dom->getElementsByTagName('p')作为$tag){
//$tag->nodeValue=str_replace(“

]]>”,“”,$tag->nodeValue); 如果(!empty($tag->nodeValue)){ //$tag->nodeValue=str_replace(“&&&

]]>”,“”,$tag->nodeValue); $xml.=''.stripslashes($tag->nodeValue)。“

”]]>; } } $xml.=“”; $xml.=''; }
示例:

//Next replace all new lines with the unicode:
$xml = str_replace("\n","&#10;", $xml);

请考虑提供实际代码而不是图像。如果您的潜在助手无法从您提供的示例中复制粘贴,则需要重新创建示例代码。请不要发布代码的屏幕截图,而是提供代码。
//Next replace all new lines with the unicode:
$xml = str_replace("\n","&#10;", $xml);