更新
我添加了一些日志记录,而我的第一个日志(响应)正在返回XML。但是,在将响应放入var attempts = 0;
var randomNumber;
while (randomNumber === 10) {
randomNumber = (Math.random(10 - 1) + 1);
attempts = attempts + 1;
}
document.write("It took " + attempts + " attempts");
中并记录了该变量之后,它在我的日志中为空。
simplexml_load_string
原始问题
我试图在下面使用SimpleXML解析XML。在我的代码中,我有:
$client = new Client();
$res = $client->request('GET', $url);
log_info($res->getBody()-getContents());
$orders = simplexml_load_string($res->getBody()->getContents());
log_info($orders);
这 在最近几天为我工作,但现在出现以下错误 $orders = simplexml_load_string($res->getBody()->getContents());
$orders->getNamespaces(true);
foreach ($orders->TrackInfo as $order) {
// logic
}
。不知道我在做什么错。
XML
Error: Call to a member function getNamespaces() on boolean