本文整理汇总了PHP中SimpleXMLElement::xPath方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLElement::xPath方法的具体用法?PHP SimpleXMLElement::xPath怎么用?PHP SimpleXMLElement::xPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLElement
的用法示例。
在下文中一共展示了SimpleXMLElement::xPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWeatherForLocation
/**
* So, the user wants weather, correct?
*/
public function getWeatherForLocation($sChannel, $sNickname, $sArguments)
{
if (!$sArguments) {
$this->Notice($sNickname, "USAGE: weather [Town or City name]");
return END_EVENT_EXEC;
}
$sXML = utf8_encode(file_get_contents("http://www.google.com/ig/api?weather=" . urlencode($sArguments)));
$pXML = new SimpleXMLElement($sXML);
$pCurrentConditions = $pXML->xPath("//xml_api_reply/weather/current_conditions");
$pLocationDetails = $pXML->xPath("//xml_api_reply/weather/forecast_information");
if (!$pLocationDetails) {
$this->Notice($sNickname, "Nope, give me a real town name, please!");
return END_EVENT_EXEC;
}
$this->Message($sChannel, "{b}Weather for {c:darkblue}{$pLocationDetails[0]->city['data']}", FORMAT);
$this->Message($sChannel, "{c:darkgreen}Condition:{r} {$pCurrentConditions[0]->condition['data']}", FORMAT);
$this->Message($sChannel, "{c:darkgreen}Temperature:{r} {$pCurrentConditions[0]->temp_c['data']}°C, {$pCurrentConditions[0]->temp_f['data']}°F", FORMAT);
$this->Message($sChannel, "{c:darkgreen}Humidity:{r} " . substr($pCurrentConditions[0]->humidity['data'], 10), FORMAT);
$this->Message($sChannel, "{c:darkgreen}Wind Speed:{r} " . substr($pCurrentConditions[0]->wind_condition['data'], 6), FORMAT);
return END_EVENT_EXEC;
}