$str1 = "http://user.qzone.qq.com/1340477530#!app=2&pos=1300412602";
$xml = '<?xml version="1.0" encoding="utf-8"?>'."\r\n";
$xml .= '<user>'."\r\n";
$xml .= "\t".'<person_siteurl>'.$str1.'</person_siteurl>'."\r\n";
$xml .= '</user>'."\r\n";
$sxe = new SimpleXMLElement($xml);
$sxe->asXML('test.xml');运行后发现如下错误,arning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 3: parser error : EntityRef: expecting ';' in C:\wamp\www\test\a.php on line 18
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <person_siteurl>http://user.qzone.qq.com/1340477530#!app=2\&pos=1300412602</per in C:\wamp\www\test\a.php on line 18
将$str1中的 "&" 去掉后就正常了,这是为什么啊。。有什么解决办法吗?谢谢~~
解决方案 »
- 只知道珍珠,不懂造项链
- 写一个登录界面,用户名+密码+验证码。这单独写,我会写。但是我叫我连得一起写,就会写了,求助!!!
- dw8中使用php+sql连接数据库抱错"http 500"
- 我新建了一个a.htm,然后嵌入baidu搜索代码,一切正常,但点击按钮后,搜索结果会在另外一个页面打开,如
- 不用按提交键,留言页面只需一刷新就会往数据库上添加一条前一次添加过的数据,求解决!!~~
- 刚注册的域名,大家来拍砖!!
- PHP为何连不上Mysql?
- 高分问题!!!!!!!!!怎样得到当前的星期?并把它转化为int?谢谢了,请给出代码我给高分
- thinkphp 日志记录没有文件生成
- 正则匹配到多个结果,如何取最后一个结果?
- 上传csv文件不成功
- php中<<<是什么符号
$xml_string="<?xml version='1.0'?>
<users>
<user id='398'>
<name>Foo</name>
<email>[email protected]</name>
</user>
<user id='867'>
<name>Foobar</name>
<email>[email protected]</name>
</user>
</users>";
//load the xml string using simplexml
$xml = simplexml_load_string($xml_string);
//loop through the each node of user
foreach ($xml->user as $user)
{
//access attribute
echo $user['id'], ' ';
//subnodes are accessed by -> operator
echo $user->name, ' ';
echo $user->email, '<br />';
}