我有以下字符串:
$string='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bac="http://backupbank.com/"> <soapenv:Header/> <soapenv:Body>
<bac:CreateUser>
<bac:request>
<!--Optional:-->
<bac:username>anandneema</bac:username>
<bac:product>Workstation</bac:product>
<bac:credentials>
<bac:server>serveripaddress</bac:server>
<bac:user>username</bac:user>
<bac:password>password</bac:password>
</bac:credentials>
</bac:request>
</bac:CreateUser> </soapenv:Body> </soapenv:Envelope>';
$xmldata=simplexml_load_string($string);
echo "<pre>"; print_r($xmldata);
它不解析数据。
但是当我使用:
$string='<soapenv:Envelope> <soapenv:Header/> <soapenv:Body>
<bac:CreateUser>
<bac:request>
<!--Optional:-->
<bac:username>anandneema</bac:username>
<bac:product>Workstation</bac:product>
<bac:credentials>
<bac:server>serveripaddress</bac:server>
<bac:user>username</bac:user>
<bac:password>password</bac:password>
</bac:credentials>
</bac:request>
</bac:CreateUser> </soapenv:Body> </soapenv:Envelope>';
$xmldata=simplexml_load_string($string); echo "<pre>"; print_r($xmldata);
实际上,当我删除属性时:xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bac="http://backupbank.com/"
然后解析数据
任何人都可以向我建议可能是什么问题?