假设我从PHP内网搜索引擎里搜索出一组结果,每一个结果都有一个超链。
点击超链的同时,PHP调用该结果同数据库里的所有字段值,并生成一个临时的XML文件。
当点击下一个超链时,所生成的XML覆盖先前的XML文件,关闭该页面后XML文件自动清除。XML格式
<title>=$name(XML文件名)
<item>=$item
<title>=$title(ITEM名)
<link>=$link
<description>=$description

解决方案 »

  1.   

    没测试, 自己玩.<?php
    $out = array(
      'name'=>'test file',
      'item'=>'item01',
      'title'=>'title01',
      'link'=>'link01',
      'description'=>'description01',
    );// 下面两句是重点.
    header( "Content-type:   text/xml"); 
    header( "Content-Disposition:   attachment;   filename={$out['name']}"); $outTpl = <<<EOT
    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <name>{name}</name>
      <item>{item}</item>
      <title>{title}</title>
      <link>{link}</link>
      <description>{description}</description>
    </root>
    EOT;$outRet = $outTpl;
    $outRet = str_replace('{name}', $out['name'], $outRet);
    $outRet = str_replace('{item}', $out['item'], $outRet);
    $outRet = str_replace('{title}', $out['title'], $outRet);
    $outRet = str_replace('{link}', $out['link'], $outRet);
    $outRet = str_replace('{description}', $out['description'], $outRet);echo $outRet;
    exit;
    ?>
      

  2.   

    用ajax应该就比较容易实现了吧
      

  3.   

    使用dom生成很容易,但是关闭就清除,,怎么弄?
      

  4.   

    1楼的很强大,CSDN果然高手如云。以后再也不去百度,天涯了。
    不过弱弱的问一下:如果输出的XML保存到:temp/test.xml,代码加在哪?
      

  5.   

    以写如文件的方式将$outRet;
    写到temp/test.xml就可以了
      

  6.   

    5楼大大,终于又浮现了。
    虽然小弟还没有正式搞定,
    但是看了mrshelly和你的代码指点,相信很快就会搞定。
    结贴啦。