Receive XML - PHP


Receive XML - PHP

我已发送.php:

<?
 if( $curl = curl_init() ) {
    curl_setopt($curl, CURLOPT_URL, 'http://www.example.com');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
    $out = curl_exec($curl);
    echo $out;
    curl_close($curl);
  }
?>

并收到.html:

 function makeRequestXML(url) {
            http_request = false;
            ...
            http_request.onreadystatechange = ContentsXML;
            http_request.open('GET', 'send.php', true);
            http_request.send(null);
        }
function ContentsXML() {
    alert(http_request.readyState);
    alert(http_request.status);
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                number_checkbox = 0;
                var xmldoc = http_request.responseXML;

但 XMLDOC 不是 XML。我想发送 XML($out)。我该怎么做?

从你的问题中不清楚$out包含什么,使用 PHP,你可以做一些字符串操作将值转换为 XML 字符串(以防该值可以转换为字符串):

 printf('<root>%s</root>', htmlspecialchars($out));

echo行替换为该行,它可能已经起作用了。否则,您需要更具体地询问内容。