我在使用&
php 创建的 in xml 字符串时遇到问题SimpleXMLElement
。例如以下:
<?php
$xml = new SimpleXMLElement("<?xml version='1.0' encoding='UTF-8'?><links></links>");
$xml->addChild("url","https://www.somewhere.com?a=1&b=2");
echo $xml->asXML();
?>
运行时给我:
<?xml version="1.0" encoding="UTF-8"?>
<links><url>https://www.somewhere.com?a=1</url></links>
我已经尝试过:
...
$xml->addChild("url","https://www.somewhere.com?a=1&b=2");
...
并得到:
...
<links><url>https://www.somewhere.com?a=1&b=2</url></links>
如何得到:
...
<links><url>https://www.somewhere.com?a=1&b=2</url></links>