I essentially have an xml file in which one attribute is a link which has &
's. 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. But this is not working. the xml parse keeps failing. 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 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. But I need something robust and not just for &'s