XML cannot be parsed & amp;. how can this problem be solved? PHPcode $ str1 & quot; user. qzone. qq. com1340477530 #! App2 & amp; pos1300412602 & quot; $ xml & lt ;? Xmlversion & quot; 1.0 & quot; encoding & quot; UTF-8 & quot; XML cannot be parsed. how can this problem be solved?
PHP code
$str1 = "http://user.qzone.qq.com/1340477530#!app=2&pos=1300412602";$xml = '
'."\r\n";$xml .= '
'."\r\n";$xml .= "\t".'
'.$str1.'
'."\r\n";$xml .= '
'."\r\n";$sxe = new SimpleXMLElement($xml);$sxe->asXML('test.xml');
The following error is found after running,
HTML code
arning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 3: parser error : EntityRef: expecting ';' in C:\wamp\www\test\a.php on line 18Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:
http://user.qzone.qq.com/1340477530#!app=2\&pos=1300412602
After "&" in $ str1 is removed, it will be normal. why .. Is there any solution? Thank you ~~
------ Solution --------------------
$ Xml. = "\ t ".' '.Html entities ($ str1 ).' '. "\ R \ n ";