【发布时间】:2010-08-12 11:40:40
【问题描述】:
我的数据库中有一些有效的字符串,但是当我将它们包含在 UTF-8 XML 输出的属性中时,它们会给我以下错误:
XML 解析错误:格式不正确
我当前的代码(简化):
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
echo '<root attribute="' . htmlentities($string_from_hell) . '">';
在将它们包含在 XML 属性中之前,我应该如何格式化这些字符串?
$string_from_hell 的可能值:(不知道它是否会正确显示)
【问题讨论】:
-
我不会在这里使用“消毒”这个词。 “格式化”对我来说似乎更合适。
-
@Col。弹片你是对的。已编辑。
标签: php xml string encoding utf-8