xml如下:
<root>
<organizations>
<organization>
<info>
<orgID>1234</orgID>
<orgName>XYZ Company</orgName>
<address>
<address1>1 Main Street</address1>
<city>Somewhere</city>
<state>MI</state>
<zip>12334</zip>
</address>
</info>
</organization>
</organizations>
</root>
代码如下:
$ind = strpos($xmlResponse, "<");
$xml = simplexml_load_string(substr($xmlResponse, $ind));
//echo $xml;
$orgList = $xml->organizations->children();
foreach($orgList as $orgList)
{
echo $orgList->orgName;
}
我收到以下错误:
Warning: main() [function.main]: Node no longer exists in...
违规行是
foreach($orgList as $orgList)
谁能告诉我我做错了什么?我尝试通过 50 种不同的方式访问 xml,要么得到那个错误,要么得到一个空的 xml 对象。
提前致谢!