[英]php htmlspecialchars() not working
I essentially have an xml file in which one attribute is a link which has &
's. 我基本上有一个xml文件,其中一个属性是具有
&
的链接。 I'm unable to parse this with simplexml_load_string
so I'm using htmlspecialchars
on it before xml parse and htmlspecialchars_decode
after xml parse. 我无法用解析这个
simplexml_load_string
所以我使用htmlspecialchars
就可以了XML解析和前htmlspecialchars_decode
XML解析之后。 But this is not working. 但这是行不通的。 the xml parse keeps failing.
xml解析不断失败。 My code is as follows.
我的代码如下。
public static function parseXMLStr($xml_str) {
$xml_str=htmlspecialchars($xml_str, ENT_NOQUOTES);
self::$xml=simplexml_load_string($feature_ban_xml_str);
if(isset(self::$xml->link)) {
.....
What is going wrong? 怎么了? Am i understanding something incorrectly?
我理解不正确吗?
edit: xml 编辑:xml
<?xml version="1.0" encoding="UTF-8"?>
<link>
<sublink active="true" redirect="http://abc.def.com/abcdef?id=&cId=45&kId=kA16000">
</sublink>
</link>
I have to add, str_replace('&','&','')
and back works well. 我必须添加
str_replace('&','&','')
并返回正常工作。 But I need something robust and not just for &'s 但是我需要强大的功能,而不仅仅是&的
如果您只想编码属性的链接,则可以使用url_encode,url_decode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.