<Error xmlns="urn:yahoo:api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://api.yahoo.com/Api/V1/error.xsd">
The following errors were detected:
<Message>limit exceeded</Message>
</Error>
$geocodeURLHomexml = file_get_contents('http://query.yahooapis.com/v1/public/yql?q=' . urlencode($queryhome) . '&format=xml');
如果显示超出的消息,我想运行google api而不是如何在PHP中执行此操作
请帮忙
答案 0 :(得分:2)
我真的不知道你在问什么,所以我在这里猜测:
这是从XML中提取<Message>
的方法:
$xml = simplexml_load_string($x); // assume XML in $x
$msg = (string)$xml[0]->Message[0];
或只是
$msg = (string)$xml->Message; //thanks to cbuckley!
然后你可以查看$msg
并做你喜欢的事情:
if ($msg == "limit exceeded") {
echo "foo: $msg";
} else {
echo "bar: $msg";
}
查看实际操作:https://eval.in/128932