Home >Backend Development >PHP Tutorial >唠叨老大还在么?XML解析出错,5555

唠叨老大还在么?XML解析出错,5555

WBOY
WBOYOriginal
2016-06-13 10:01:59768browse

唠叨老大还在么?XML解析出错求助,5555
 
咔咓吚.

怎么确保标签中的字符符合XML?要做什么处理?
真的很难确保XML文档准确性,让它能够让PHP的XML解析函数解析
有没有正则之类的XML解析器。
我只想解析这个文档,如何去掉/转意这些字符?这些字符都包括什么字符?

谢谢

------解决方案--------------------
用UTF-8应该不会存在这个问题

1.改为

咔咓吚.

2.将xml文件用记录本另存为 utf-8格式

3.PHP文件本身也用记事本存为utf-8

4.在PHP文件头部加上
header( 'Content-type:text/html;charset=utf-8 ');


欢迎加入PHP爱好者QQ群:30169840
------解决方案--------------------
呵呵,UTF-8 的编码格式应该没有什么问题。
但是,估计楼主不喜欢 UTF-8 这种格式吧。

------解决方案--------------------
我帮你顶起来。期待答案。
------解决方案--------------------

------解决方案--------------------
不用utf-8编码也可以,我自己写的程序,只有php程序,编码都是gb2312的,刚开始也报编码错误那个,后来改成utf-8不行,结果都改成gb2312就好了!有人说,好像只要保证几个页面的编码一致就可以了,具体还有待验证!
------解决方案--------------------
jom_ch 就回答到点上了.
只是CSDN自动把 "

.]]>
------解决方案--------------------
$str = " 咔咓吚. ";
//.....
$str = preg_replace( "/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/ ", ' ', $str);
$str = htmlspecialchars($str);
------解决方案--------------------
上面弄错了
htmlspecialchars 应该先转码再放到 里的
------解决方案--------------------
呵呵,我一般这样:

function SBC_DBC($Str)
{
//---- 全角都转成半角 ----
$Queue = Array(
'0 ' => '0 ', '1 ' => '1 ', '2 ' => '2 ', '3 ' => '3 ', '4 ' => '4 ',
'5 ' => '5 ', '6 ' => '6 ', '7 ' => '7 ', '8 ' => '8 ', '9 ' => '9 ',
'A ' => 'A ', 'B ' => 'B ', 'C ' => 'C ', 'D ' => 'D ', 'E ' => 'E ',
'F ' => 'F ', 'G ' => 'G ', 'H ' => 'H ', 'I ' => 'I ', 'J ' => 'J ',
'K ' => 'K ', 'L ' => 'L ', 'M ' => 'M ', 'N ' => 'N ', 'O ' => 'O ',
'P ' => 'P ', 'Q ' => 'Q ', 'R ' => 'R ', 'S ' => 'S ', 'T ' => 'T ',
'U ' => 'U ', 'V ' => 'V ', 'W ' => 'W ', 'X ' => 'X ', 'Y ' => 'Y ',
'Z ' => 'Z ', 'a ' => 'a ', 'b ' => 'b ', 'c ' => 'c ', 'd ' => 'd ',
'e ' => 'e ', 'f ' => 'f ', 'g ' => 'g ', 'h ' => 'h ', 'i ' => 'i ',

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn