$xml = simplexml_load_file('http://quest7.myddt.com.br/serverlist.ashx');
echo $xml->Result->Item->Port;
//echo '<pre>';
//var_dump($xml);
错误:尝试获取非对象的属性修复?
答案 0 :(得分:1)
已加载根元素,因此您跳过Result
,然后Port
是Item
的属性,因此您可以像数组索引一样引用它:
<?php
$xml = simplexml_load_file('http://quest7.myddt.com.br/serverlist.ashx');
if ($xml !== false){
echo $xml->Item['Port'];
} else {
echo "something went wrong...";
}
8000