登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

淘尽网 官方博客

淘尽网http://www.tao3w.com做最好的比价网站

 
 
 

日志

 
 

鸟人公社开发随笔  

2010-10-28 17:55:33|  分类: PHP |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

header ( "Content-type:text/html;Charset=utf-8" );
$url = "http://www.google.com/ig/api?weather=shenzhen"; //加载XML内容
$dom = new DOMDocument();
$dom->load ( $url );
$xpath = newDOMXPath ( $dom );
$element = $xpath->query ( "/xml_api_reply/weather/current_conditions" )->item ( 0 );
$condition = get_google_xml_data ( $element, "condition" );
$temp_c = get_google_xml_data ( $element, "temp_c" );
echo '天气:', $condition, '<br/>';
echo '温度:', $temp_c, '<br/>';
function get_google_xml_data($element, $tagname)
{
 $tags = $element->getElementsByTagName ( $tagname );
 //取得所有的$tagname if($items->length>1){
 return $items;
}
$tag = $tags->item ( 0 ); //获取第一个以$tagname命名的标签
if($tag->hasAttributes ())
{ //获取data属性
 $attribute = $tag->getAttribute ( "data" );
 return $attribute;
}
else
{
 returnfalse;
}

发现代码不能运行,提示有错误【"Warning: domdocument::domdocument() expects at least 1 parameter"】

解决如下:

问题的解决方法:http://bugs.php.net/bug.php?id=45538
php5 在 windows 下运行时,不需要在 php.ini 里声明 php_domxml.dll,加个分号注释起来就行了。

If you use PHP 5 in windows, you don't need to declare php_domxml.dll in your php.ini file.
so u can give comment in the line php_domxml.dll in your php.ini file.
you only need to comment it out, but do not delete the php_domxml.dll file in the ext directory.

  评论这张
 
阅读(403)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018