Php 解析xml问题
我试图用PHP和simplexml加载文件解析这个,但它没有显示任何内容 我哪里做错了?谢谢Php 解析xml问题,php,xml,parsing,Php,Xml,Parsing,我试图用PHP和simplexml加载文件解析这个,但它没有显示任何内容 我哪里做错了?谢谢 $results = simplexml_load_file($url); foreach($results->Location() as $location) { foreach($location->Address() as $address) { foreach($address->Areas() as $areas) { foreach($areas
$results = simplexml_load_file($url);
foreach($results->Location() as $location) {
foreach($location->Address() as $address) {
foreach($address->Areas() as $areas) {
foreach($areas->Area as $area) {
echo $area->area;
echo "<br />";
}
}
}
}
$results=simplexml\u load\u文件($url);
foreach($results->Location()作为$Location){
foreach($location->Address()作为$Address){
foreach($address->Areas()作为$Areas){
foreach($areas->面积为$Area){
echo$区域->区域;
回声“
”;
}
}
}
}
如果已启用,则会看到
Fatal error: Call to undefined method SimpleXMLElement::Location()
您正在尝试使用方法调用访问元素,例如
foreach($results->Location() as $location) {
应该是什么时候
foreach($results->Location as $location) {
其他元素也一样。而且,它不是
$area->area
,而是$area
完整固定代码:
$results = simplexml_load_file($url);
foreach($results->Location as $location) {
foreach($location->Address as $address) {
foreach($address->Areas as $areas) {
foreach($areas->Area as $area) {
echo $area;
echo "<br />";
}
}
}
}
如果已启用并启用,则会看到
Fatal error: Call to undefined method SimpleXMLElement::Location()
您正在尝试使用方法调用访问元素,例如
foreach($results->Location() as $location) {
应该是什么时候
foreach($results->Location as $location) {
其他元素也一样。而且,它不是
$area->area
,而是$area
完整固定代码:
$results = simplexml_load_file($url);
foreach($results->Location as $location) {
foreach($location->Address as $address) {
foreach($address->Areas as $areas) {
foreach($areas->Area as $area) {
echo $area;
echo "<br />";
}
}
}
}
在调用
simplexml\u load\u file
之后,输入var\u dump($results)
并显示返回的内容。还有,你检查过你的日志了吗?并将error_reporting设置为E_ALL
以检查错误…$xml=simplexml\u load_file($url);var_dump($xml);这会在调用simplexml\u load\u file
之后立即将所有内容转储回来,放入var\u dump($results)
并显示返回的内容。还有,你检查过你的日志了吗?并将error_reporting设置为E_ALL
以检查错误…$xml=simplexml\u load_file($url);var_dump($xml);那会把所有东西都倒回去