我有这段代码:
$xml_response = $linkedin->getProfile("~:(id,firstName,lastName,email-address)");
生成以下结果xml:
<person>
<id>c3g9fdgdbP9-</id>
<first-name>Shoen</first-name>
<last-name>Vergue</last-name>
<email-address>manager@glob....beg.com</email-address>
</person>
如何获取电子邮件价值?
我试过了:
$mail=$xml_response['email-address'];
但它什么都不返回
提前谢谢
答案 0 :(得分:1)
查看SimpleXML Parser,尝试以下内容:
libxml_use_internal_errors(true);
$xml = simplexml_load_string($xml_response);
if ($xml === false) {
echo "Failed loading XML: ";
foreach(libxml_get_errors() as $error) {
echo "<br>", $error->message;
}
} else {
echo $xml->{"email-address"};
}