卷曲错误无法解析主机:saved_report.xml;没有请求类型的数据记录。 [英] Curl error Could not resolve host: saved_report.xml; No data record of requested type"

查看:67
本文介绍了卷曲错误无法解析主机:saved_report.xml;没有请求类型的数据记录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php





error_reporting(E_ALL);

$url = 'saved_report.xml';


define('XML_HEADER', '*RWRESPONSE*RESPONSE*DATA*HEADER*COLUMN');
define('XML_ROW', '*RWRESPONSE*RESPONSE*DATA*ROW*COLUMN');

$headers = array();
$rows = array();

function startTag($parser, $data) { 
    global $current_tag; 
    $current_tag .= "*$data"; 
} 

function endTag($parser, $data) { 
    global $current_tag; 
    $tag_key = strrpos($current_tag, '*'); 
    $current_tag = substr($current_tag, 0, $tag_key); 
} 

function contents($parser, $data) { 
    global $current_tag, $headers, $rows;
    switch($current_tag) { 
        case XML_HEADER: 
            array_push($headers, $data);
            break; 
        case XML_ROW:
            array_push($rows, $data);
            break; 
    } 
} 




// fetch the report
$curl_object = curl_init();
curl_setopt($curl_object, CURLOPT_URL, $url);
curl_setopt($curl_object, CURLOPT_HEADER, 0);
curl_setopt($curl_object, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl_object, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_object, CURLOPT_SSL_VERIFYHOST, 0);

$result = curl_exec($curl_object);
$error = curl_error($curl_object);
$info = curl_getinfo($curl_object);
curl_close($curl_object);

if ($error) {
    die("An error occured while fetching the report\n");
}


// process the report
$xml_parser = xml_parser_create(); 
xml_set_element_handler($xml_parser, "startTag", "endTag"); 
xml_set_character_data_handler($xml_parser, "contents"); 

if(!(xml_parse($xml_parser, $result))){ 
    die("Error on line " . xml_get_current_line_number($xml_parser)); 
} 
xml_parser_free($xml_parser);

for($i = 0; $i \n";
}

echo '
'; echo "$headers[3]: $rows[3]
\n"; echo "$headers[4]: $rows[4]
\n"; ?>

在运行此脚本时,出现错误

while running this script , i am getting an error

无法解析主机:saved_report.xml;没有请求类型的数据记录

"Could not resolve host: saved_report.xml; No data record of requested type"

我无法解决此问题。

推荐答案

您需要指定文件的完整路径,例如:

You need to specify full path of the file, e.g.:

$url = 'http://example.com/saved_report.xml';

因为curl不适用于相对URL

as curl doesn't work with relative URLs

这篇关于卷曲错误无法解析主机:saved_report.xml;没有请求类型的数据记录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆