I got it worked out with help from Hannu L., thanks for the suggestion. The xml string ($xmlstring) converts in to an array with several nested arrays, so the following code will traverse the whole tree and output the "Query" data.
try { //a new simpleXML iterator object $sxi =new SimpleXMLIterator($xmlstring); foreach ( $sxi as $node ) { foreach($node as $k=>$v) { for ($i=0; $i<count($v); $i++) echo $v->row[$i]["Query"].'<br />'; } } } catch(Exception $e) { echo $e->getMessage(); } Here is the reference Hannu suggested: http://www.phpro.org/tutorials/Introduction-to-SPL.html#11 rwhite35 On Jun 5, 8:24 pm, rwhite35 <rwh...@echotimesoftware.com> wrote: > Hello, > > I've created a Search Query report and want output the content of an > XML object for this report. The XML object is created with PHP 5, > SimpleXML function. The report contains all the data I want, print_r > outputs the SimpleXMLObject structure and its all there. But if I > want to target the "Query" element and loop through the array, I only > get the first row of that element and not the subsequent rows. > > Here's my code: > > //create a variable to hold the XML string > //works > //downloadXmlReport is a PHP APIlity function, reportID was already > created earlier > $xmlReport = downloadXmlReport($reportID); > > //create a simpleXML Object that will require additional processing > //works > $xmldata = simplexml_load_string($xmlReport); > //echo "<pre>"; > //print_r($xmldata); > //echo "</pre>"; > > //get search queries from the XML object xmldata > foreach($xmldata->table->rows as $phrase) { > echo "<p>".$phrase->row["Query"]."<br />\n"; > echo "<br />";} > > //outputs the value of row[Query], once > > //test result with conditional statement > $i=0; $i<count($xmldata); > $searchPhrase=$xmldata->table->rows->row[$i]["Query"]; > print("The second technique: ".$searchPhrase); > $i++;} > > echo "</p><br />"; > //outputs the value of row[Query], once > > --- > both code blocks output the first child of the "row" element, but not > the next. The structure of the XML object is: > [table] > -> [rows] > --> [row][0][Query] > > Help? Thanks in advance. > > rwhite35 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en -~----------~----~----~----~------~----~------~--~---