×

Loading...
Ad by
Ad by

请教PHP问题:如何在Browser中格式化显示自己产生的UTF-8 RSS feed xml string?

我用PHP产生了一个UTF-8 RSS feed xml string,字符串的开头是:<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="rsspretty.xsl" version="1.0"?>。字符串的开头没有BOM字符。但用header("Content-Type: text/xml; charset=utf-8") 和echo显示时,串的开头被加入几个BOM, 得到 “The XML page cannot be displayed。Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. Invalid at the top level of the document“ 错误。请问应如何格式化显示UTF-8 RSS feed ?
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / 请教PHP问题:如何在Browser中格式化显示自己产生的UTF-8 RSS feed xml string?
    我用PHP产生了一个UTF-8 RSS feed xml string,字符串的开头是:<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="rsspretty.xsl" version="1.0"?>。字符串的开头没有BOM字符。但用header("Content-Type: text/xml; charset=utf-8") 和echo显示时,串的开头被加入几个BOM, 得到 “The XML page cannot be displayed。Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. Invalid at the top level of the document“ 错误。请问应如何格式化显示UTF-8 RSS feed ?
    • 用什么函数生成的RSS feed xml string ? SHOW出来看一下。
      • 谢谢你的关注。前几天忙没时间管这个事情,今天又试了一下,发现从数据库取出的内容有字符如' 和 " , 需要用addslashes处理后再进行串操作。