English 中文(简体)
utf8_decode wrong with ampersand (&)
原标题:utf8_decode error with ampersand (&)

我一直在制作一份载有XML法典的APIC。 例如,APIC将返回:

<message>hello, this is a message &amp; it used htmlsepcialchars</message>

我正在使用文档“植被-污染物”和简单的xml_load_string()将退回的信息输入一个阵列。

然后,我使用utf8_decode()将电文转换为接收网站的一个友好点。 然而,我收到以下信息,其中向邮局(和)指出了:

Warning: main() [function.main]: unterminated entity reference 

由于邮局,电文的其余部分被压缩。 任何关于如何解决这一问题的想法?

最佳回答

本人的答案,用户错误。 我的法典基本上再次 escaping。

问题回答

似乎你们的安乐器没有这样编码,要么是双重编码,要么把它放在裁谈会的实地。

Usually special characters like that should be put in CDATA fields. it saves the trouble of having to encode. php DOM creation functions have what you need.


$doc->createCDATASection

并且当然:

and http://fr.php.net/manual/en/function.domdocument-create-cdata-section.php

Well, simpleXML strings must be utf8 encoded, and values entities should be escaped. Is utf_decode() really necessary in your code ?





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签