现在我需要接受一个网络传过来的xml文件,http://bestrip.vicp.cc:352/ib_tranx_req.asp?sessionid=26dce5f1c8a338652bff7d2219dd0ffb&termid=&cmd=av&disp_special=1,这个是网络传过来的文件,$doc = new DOMDocument; 
$doc->load('http://bestrip.vicp.cc:352/ib_tranx_req.asp?sessionid=26dce5f1c8a338652bff7d2219dd0ffb&termid=&cmd=av&disp_special=1'); 
$book = $doc->documentElement; 
$airline = $book->getElementsByTagName('airline'); 
我这样怎么不对呢,为什么我改成了$doc->load('a.xml'); 这样就可以呢,为什么不能接受网络传过来的网址参数呢?请高手赐教……

解决方案 »

  1.   

    $doc->load('a.xml'); 
    是本地议论,远程的应看是否打开了相应开关你可以先load()一个xml试试,应该没问题的有问题的话贴出错提示
      

  2.   

    另外,人家那sid可能是动态生成的,可能是传递的session_id,你没有登录,打不开的
      

  3.   

    我的意思就是我程序怎么弄,才能获取别人发给我的网址xml参数呢
      

  4.   

    因为我需要和人家共享XML文件,都是通过网络传过来的
      

  5.   

    $doc = new DOMDocument; 
    $doc->file_get_contents('http://bestrip.vicp.cc:352/ib_tranx_req.asp?uid=wz001&sessionid=26dce5f1c8a338652bff7d2219dd0ffb&termid=&cmd=av&verify=0&start_city=SHA&arrive_city=PEK&date=2008-11-21');
    $book = $doc->documentElement; 
    我用file_get_contents获取网络过来的也不行,到底是哪个地方出现问题了呢?
      

  6.   

    $doc->file_get_contents('http://bestrip.vicp.cc:352/ib_tranx_req.asp?uid=wz001&sessionid=26dce5f1c8a338652bff7d2219dd0ffb&termid=&cmd=av&verify=0&start_city=SHA&arrive_city=PEK&date=2008-11-21'); 改成下边这个试试
    $doc->file_get_contents('http://bestrip.vicp.cc:352/ib_tranx_req.asp?uid=wz001&sessionid=26dce5f1c8a338652bff7d2219dd0ffb&termid=&cmd=av&verify=0&start_city=SHA&arrive_city=PEK&date=2008-11-21'); 
      

  7.   

    header('Content-Type:text/xml;charset=utf-8');
    对了.还要加一句.编码格式自己决定
      

  8.   

    用xml_parser_create()吧,给你个例子
    test.php
    <?php
    $parser = xml_parser_create(); //创建一个parser编辑器xml_set_element_handler($parser, "startElement", "endElement");//设立标签触发时的相应函数 这里分别为startElement和endElenmentxml_set_character_data_handler($parser, "characterData");//设立数据读取时的相应函数$xml_file="http://www.abc.com/1.xml";//指定所要读取的xml文件,可以是url$filehandler = fopen($xml_file, "r");//打开文件
     
    while ($data = fread($filehandler, 4096))
    {
        xml_parse($parser, $data, feof($filehandler));
    }//每次取出4096个字节进行处理
    fclose($filehandler);
    xml_parser_free($parser);//关闭和释放parser解析器$name=false;
    $position=false;
    function startElement($parser_instance, $element_name, $attrs) //起始标签事件的函数 {
       global $name,$position;
       if($element_name=="NAME")
       {
       $name=true;
       $position=false;
       echo "名字:";
      }
      if($element_name=="POSITION")
       {$name=false;
       $position=true;
       echo "职位:";
      }
    }function characterData($parser_instance, $xml_data) //读取数据时的函数{
       global $name,$position;
       if($position)
        echo $xml_data."<br>";
        if($name)
         echo $xml_data."<br>";
    }function endElement($parser_instance, $element_name) //结束标签事件的函数
    {
      global $name,$position;
    $name=false;
    $position=false;
    }
    ?>
    1.xml
    <?xml version="1.0" encoding="gb2312"?>
    <employees>
    <employee>
    <name>test1</name>
    <position age="45">TEST11</position>
    </employee>
    <employee>
    <name>TEST2</name>
    <position age="45">TEST22</position>
    </employee>
    </employees>
      

  9.   

    查看php手册 xml-rpc那章 有详细的怎么操作XML数据的
    你的那个代码是操作XML文件的后缀名未.XML的文件的
    要采用xml-rpc的方式
      

  10.   

    基本上就是一个web service方式的,
    你构造参数向http://bestrip.vicp.cc:352/ib_tranx_req.asp发送请求,
    请求时要带上后面的参数,对方收到请求按照标准,返回一个xml给你.如果你和对方是共享xml,就和对方订好协议,是要get还是post,参数怎么传之类的.
      

  11.   

    直接file_get_contents就可以了。
    如果需要一行一行的自动分组,用file,
    多看看php,多搜索:http://76xz.com/bbs/forum-5-1.html
      

  12.   

    获取?你怎么读文件就怎么读XML
      

  13.   

    建议你使用接口来写,推荐soap或者fsockopen
      

  14.   

     jQuery和PHP实现星级评分效果特效   http://download.csdn.net/detail/yeshili/3754989