php 返回xml信息错误 - PHP / 基础编程
这个地址:http://maps.google.com/ig/api?weather=shanghai&hl=zh-cn
是google返回的一个天气预报xml
想调用到本地来:
<?php
readfile('http://maps.google.com/ig/api?weather=shanghai&hl=zh-cn');
?>
提示错误:
无法显示 XML 页。
使用 XSL 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。
--------------------------------------------------------------------------------
文本内容中发现无效字符。处理资源 'http://localhost/Flash_Weather/weather_google.php' 时出错。第 1 行,位置: 438
<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zippe...
是怎么回事呢?谢谢了..
readfile读入一个文件并写入到输出缓冲。
返回从文件中读入的字节数。如果出错返回 FALSE 并且除非是以 @readfile() 形式调用,否则会显示错误信息。
PHP code:
<?php
$data = file_get_contents('http://maps.google.com/ig/api?weather=shanghai&hl=zh-cn');
$parser = xml_parser_create();
xml_parse_into_struct($parser, $data, $values, $index);
xml_parser_free($parser);
var_dump($values);
?>
{{
相关问答:
DataSet导出xml 批处理(循环)得怎么处理
XML文件
<A>
<B>
<C>
</C>
&nb ......
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical&q ......
现在有个xml文件是<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xm ......