All pastes #976156 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-07 23:24 UTC
rendered paste body
<?php

$xmlfile = "dataread.xml";

$xml = simplexml_load_file($xmlfile);

$level = $xml->accounts->account->campaigns->campaign->adgroups;

foreach($level->adgroup as $val) {
	foreach($val->creatives as $val2) {
		foreach($val2->imageads->imagead as $val3) {
			$imagename = $val3->{'imagead-data'}->image["src"];
			echo "$imagename<br>\n";
			$imagenames[] = $imagename;
		}
	}
}

print_r($imagenames);

?>


sample output:

images/5460.jpg<br>
images/5458.jpg<br>
images/5459.jpg<br>
images/5456.jpg<br>

Array
(
    [0] => SimpleXMLElement Object
        (
            [0] => images/5460.jpg
        )

    [1] => SimpleXMLElement Object
        (
            [0] => images/5458.jpg
        )

    [2] => SimpleXMLElement Object
        (
            [0] => images/5459.jpg
        )

    [3] => SimpleXMLElement Object
        (
            [0] => images/5456.jpg
        )
}