I have php code connecting to an API:
require(dirname(__FILE__) . '/MadMimi.class.php');
$mailer = new MadMimi('XXX.org', '000');
$lists = $mailer->Lists();
var_dump($lists);
foreach ($lists as $list) {
echo $list['name']; }
var_dump
shows a XML doc in the form:
`string '<?xml version="1.0" encoding="UTF-8"?>
<lists>
<list id="8" name="#1" subscriber_count="210" display_name="Display name"/>
<list id="9" name="#2" subscriber_count="2242" display_name="Display name"/>`
...(length=2726)
but it only shows the first few lines. How do I make it show all the values?
Also I'm trying to print specific values using the foreach loop but it isn't working and I'm getting the error: Invalid argument supplied for foreach()
If foreach doesn't work how else can I obtain values from the XML doc?
If I do
$xml=simplexml_load_string($lists) or die("Error: Cannot create object");
print_r($xml);
I get:
SimpleXMLElement Object ( [list] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 8 [name] => #1 [subscriber_count] => 210 [display_name] => Display name ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 9 [name] => #2 [subscriber_count] => 2242 [display_name] => Display name ) )
how do I write a foreach loop for this?