做了个留言板,php操作XML本地测试成功,上传到服务器就出错,显示留言内容那部分出错Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "guestbook.xml" in E:\www\14598\3.php on line 4Notice: Trying to get property of non-object in E:\www\14598\3.php on line 5Warning: Invalid argument supplied for foreach() in E:\www\14598\3.php on line 5请问是什么问题呢?该怎么修改?
有guestbook.xml这个文件 
3.php这行就是$guestbook=simplexml_load_file('guestbook.xml');和下面行 
foreach($guestbook->thread as $th)

解决方案 »

  1.   

    你在服务器空间写一个phpinfo.php文件,查看一下空间的配置,看它的php.ini中xml功能有没有打开
      

  2.   

    但你这个提示应该是xml文件没有找到
      

  3.   


    XML文件名称及路径都确认没有错误呢,那会是什么原因呢?会不会是load XML文件的函数或语句错误?
      

  4.   


    恩$guestbook = new DomDocument(); //创建一个新的 DOM对象
    $guestbook->load('guestbook.xml'); //读取 XML数据
    $threads = $guestbook->documentElement; //获得 XML结构的根
    //创建一个新 thread节点
    $thread = $guestbook->createElement('thread');
    $threads->appendChild($thread);
    //在新的 thread节点上创建 title标签
    $title = $guestbook->createElement('title');
    $title->appendChild($guestbook->createTextNode($_POST['title']));
    $thread->appendChild($title);
    //在新的 thread节点上创建 author标签
    $author = $guestbook->createElement('author');
    $author->appendChild($guestbook->createTextNode($_POST['author']));
    $thread->appendChild($author);
    //在新的 thread节点上创建 content标签
    $content = $guestbook->createElement('content');
    $content->appendChild($guestbook->createTextNode($_POST['content']));
    $thread->appendChild($content);
    //=========================================================
    $threads->appendChild($guestbook->createTextNode("\n"));//这样来添加换行
    //=========================================================
    //将 XML数据写入文件
    $fp = fopen("guestbook.xml", "w");
    if(fwrite($fp, $guestbook->saveXML()))
    {
    //fwrite($fp,"\r\n");
    echo "成功";
    echo " <script language='Javascript'>
          parent.location.reload();
            </script>";
    }
    else
    echo "留言提交失败";
    fclose($fp); 
      

  5.   

     很明显你的foreach 的问题,看你的xsl文件
      

  6.   


    我没XSL文件呢,纯PHP+XML+HTML
    XML文件是没错的