Expand|Select|Wrap|Line Numbers
- $xml = simplexml_load_file($request_url) or die("feed not loading");
Expand|Select|Wrap|Line Numbers
- echo "<pre>";
- var_dump($xml);
- echo "</pre>";
Expand|Select|Wrap|Line Numbers
- object(SimpleXMLElement)#1 (2) {
- ["@attributes"]=>
- array(1) {
- ["Type"]=>
- string(5) "Popup"
- }
- ["ad"]=>
- object(SimpleXMLElement)#2 (6) {
- ["url"]=>
- object(SimpleXMLElement)#3 (0) {
- }
- ["cpvrate"]=>
- string(5) "0.005"
- ["creativeid"]=>
- string(10) "0204499385"
- ["campaignid"]=>
- string(12) "2-0210728303"
- ["max-imp-per-user"]=>
- string(1) "1"
- ["frequency-period"]=>
- string(2) "24"
- }
- }
- object(SimpleXMLElement)#1 (1) {
- ["@attributes"]=>
- array(1) {
- ["Type"]=>
- string(7) "NoPopup"
- }
- }
In my php code I'm assigning variables like this:
Expand|Select|Wrap|Line Numbers
- $adtype = (string) $xml->Type;
- $outurl = (string) $xml->ad->url;
- $cpvr = (string) $xml->ad->cpv_rate;
- $crid = (string) $xml->ad->creativeid;
- $caid = (string) $xml->ad->campaignid;
- $mipu = (string) $xml->ad->max-imp-per-user;
- $fp = (string) $xml->ad->frequency-period;