Nextag API - SimpleXML 不起作用
我正在尝试使用 Nextag 相对简单的 API 来提取数据。
您可以通过访问查看示例 XML 响应:
http://api.nextag .com/buyer/synd.jsp?token=AgAg-V6vGl$rkqkUtxvd&ver=15&search=LG%2047LE8500
但我无法让简单的 XML 正确处理这些数据。我要么收到构造函数错误,要么收到空对象。
这是我到目前为止所拥有的:
$xml = file_get_contents('http://api.nextag.com/buyer/synd.jsp?token=AgAg-V6vGl$rkqkUtxvd&ver=15&search=LG%2047LE8500');
$simple_xml = new SimpleXMLElement($xml);
并且 $simple_xml 始终是一个空对象。
响应数据有问题吗?我做错了什么吗? Simple XML 是否不兼容?如果是,我应该怎么做?
感谢您的帮助!
更新:肖恩的答案很有用,因为它帮助克服了错误,但数据没有被加载,只有部分结构。
I'm trying to pull in data from Nextag using their relatively simple api.
You can see an example XML response by visiting:
http://api.nextag.com/buyer/synd.jsp?token=AgAg-V6vGl$rkqkUtxvd&ver=15&search=LG%2047LE8500
But I can't get Simple XML to work right with this data. I either get a constructor error or an empty object.
Here's what I have so far:
$xml = file_get_contents('http://api.nextag.com/buyer/synd.jsp?token=AgAg-V6vGl$rkqkUtxvd&ver=15&search=LG%2047LE8500');
$simple_xml = new SimpleXMLElement($xml);
And $simple_xml is always an empty object.
Is there something wrong with the response data? Am I doing something wrong? Is Simple XML just incompatible and if so, what should I do instead?
Thanks for the help!
UPDATE: Sean's answer was useful in that it helped get past the error, but the data is not being loaded, only the partial structure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您需要告诉它您要解析的名称空间。这似乎有效:
Looks like you need to tell it the namespace you want to parse. This seems to work: