1

I am developing a application using PHP. Some example code is here.

$url = "http://localhost:8080/?Xml";

$xml = simplexml_load_file($url);

foreach($xml->result->doc as $doc){
echo "<pre>".print_r($doc)."</pre>";
}

One of those item is look like this which i request.

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... ) ) 

I want to know that how I can access arrays items?

Gopa Soft
  • 111
  • 1
  • 2
  • 11
  • Is this the same question as here? http://stackoverflow.com/questions/2867575/get-value-from-simplexmlelement-object – Config Apr 07 '12 at 07:58

1 Answers1

1
foreach($doc->attributes() as $key => $value) {
    echo "$key: $value\n";
}
xdazz
  • 158,678
  • 38
  • 247
  • 274