1
我试图从使用SimpleXMLElement的URL加载XML文件。PHP SimpleXMLElement使用xmlns加载XML
我的代码基本上是这样的:
$xml = new SimpleXMLElement($url, null, true);
$网址是包含XML响应的URL字符串。如果XML中没有“xmlns”,我可以加载它。当为“xmlns”,它会导致运行时错误:
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://test.cloudapp.net:8080/api/missiondetails/1:1: parser error : Start tag expected, '<' not found in /var/www/test.com/test.php on line 10
这是XML格式的例子:
<MissionDetails xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Test.DataTransferObject"></Mission>
任何人知道如何使用“的xmlns”根加载XML节点?
预先感谢。
的错误不是由'“的xmlns”'造成的,所以它只是你在这里提到一个巧合,错误不是原因。你确实在它的消息中找到了错误的原因。哪部分错误信息很难理解? – hakre 2013-05-01 08:51:13