如何从php中的XML文档中提取值

时间:2015-05-10 09:00:28

标签: php xml

我有代码:

$map_url = "https://api.madmimi.com/audience_members.xml?username=xx@xx.org&api_key=xx";

if (($response_xml_data = file_get_contents($map_url))===false){
    echo "Error fetching XML\n";
} else {
   libxml_use_internal_errors(true);
   $data = simplexml_load_string($response_xml_data);
   if (!$data) {
       echo "Error loading XML\n";
       foreach(libxml_get_errors() as $error) {
           echo "\t", $error->message;
       }
   } else {print_r($data);}
}

print_r给出:

 SimpleXMLElement Object ( [@attributes] => Array ( [count] => 202888     
[total_pages] => 6745 [per_page] => 30 [page]
 => 1 ) 
[member] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => 

如何获取值[count] => 202888使用php?

0 个答案:

没有答案