我正在使用 PHP 开发应用程序。一些示例代码在这里。
$url = "http://localhost:8080/?Xml";
$xml = simplexml_load_file($url);
foreach($xml->result->doc as $doc){
echo "<pre>".print_r($doc)."</pre>";
}
我要求的其中一项看起来像这样。
SimpleXMLElement Object ( [@attributes] => Array ( [score] => 4.112774 [pos] => 0 ) [field] => Array ( [0] => http://www.w3schools.com/htmldom/dom_examples.asp [1] => text/html [2] => Free HTML XHTML CSS JavaScript jQuery XML DOM XSL XSLT RSS AJAX ASP .NET PHP SQL tutorials, references, examples for web building. [3] => html,css,tutorial,html5,dhtml,css3,xsl,xslt,xhtml,javascript [4] => www.w3schools.com [5] => en ) [snippet] => Array ( [0] => DOM Examples [1] => DOM HOME DOM Intro DOM Nodes DOM Node Tree DOM Methods DOM Node Access DOM Node Info DOM How To DOM Events DOM Summary DOM... ) )
我想知道如何访问数组项?