Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从rss获取xml数据 报告 ... 报告 2013年10月29日星期二23:57:00+0800 SMG-2009。版权所有。 ... 报告 ... http://Report 温度:22湿度:50%风:南方;速度:12公里/小时 ]]> getElementsByTagName('item')->item(0)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue; //$temp=iconv(“UTF-8”、“big5”和$temp); $temp=爆炸(“,$temp”); $c=$temp[1]; $h=$temp[2]; 回音$c。"----" . $H ?>_Php_Rss_Domdocument - Fatal编程技术网 ,php,rss,domdocument,Php,Rss,Domdocument" /> ,php,rss,domdocument,Php,Rss,Domdocument" />

Php 从rss获取xml数据 报告 ... 报告 2013年10月29日星期二23:57:00+0800 SMG-2009。版权所有。 ... 报告 ... http://Report 温度:22湿度:50%风:南方;速度:12公里/小时 ]]> getElementsByTagName('item')->item(0)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue; //$temp=iconv(“UTF-8”、“big5”和$temp); $temp=爆炸(“,$temp”); $c=$temp[1]; $h=$temp[2]; 回音$c。"----" . $H ?>

Php 从rss获取xml数据 报告 ... 报告 2013年10月29日星期二23:57:00+0800 SMG-2009。版权所有。 ... 报告 ... http://Report 温度:22湿度:50%风:南方;速度:12公里/小时 ]]> getElementsByTagName('item')->item(0)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue; //$temp=iconv(“UTF-8”、“big5”和$temp); $temp=爆炸(“,$temp”); $c=$temp[1]; $h=$temp[2]; 回音$c。"----" . $H ?>,php,rss,domdocument,Php,Rss,Domdocument,//------------ 现在我想检索的是$c表示温度,$h表示湿度,但它失败了,对我的代码有什么建议吗?还有风速和速度。试试: <?PHP $weather = new DOMDocument(); $weather -> load("abc.xml"); $temp=$weather->getElementsByTagName('item')->item(0)->getElementsByTagName('descri

//------------

现在我想检索的是$c表示温度,$h表示湿度,但它失败了,对我的代码有什么建议吗?还有风速和速度。

试试:

<?PHP
$weather = new DOMDocument();
          $weather -> load("abc.xml");
          $temp=$weather->getElementsByTagName('item')->item(0)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;
       //   $temp = iconv("UTF-8", "big5", $temp); 

    $temp = explode("<td>", $temp);

          $c = $temp[1];
          $h = $temp[2];

          echo $c . "----" . $h;

?>
$weather->load(“abc.xml”);
$temp=$weather->getElementsByTagName('item')->item(0)->getElementsByTagName('description')->item(0)->nodeValue;

preg_match_all('/([^)以何种方式失败?唯一带“----”的输出有效,谢谢ziollek,但我想知道为什么我的方法无效并显示为空。因为描述节点没有任何子节点。CDATA中的内容被视为文本。
<?PHP
$weather = new DOMDocument();
          $weather -> load("abc.xml");
          $temp=$weather->getElementsByTagName('item')->item(0)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;
       //   $temp = iconv("UTF-8", "big5", $temp); 

    $temp = explode("<td>", $temp);

          $c = $temp[1];
          $h = $temp[2];

          echo $c . "----" . $h;

?>
$weather -> load("abc.xml");
$temp=$weather->getElementsByTagName('item')->item(0)->getElementsByTagName('description')->item(0)->nodeValue;

preg_match_all('/<td>([^<]+)</', $temp, $matches);

$c = $matches[1][0];
$h = $matches[1][1];

echo $c . "----" . $h;