比如说把下列代码生成一个以时间命名的XML文件:  <?xml version="1.0" encoding="gb2312" ?> 
 <html author="axgle">
 <head>
  <title>this is title</title> 
  </head>
<body>
  <p id="1">this is p1</p> 
  <p id="2">this is p2</p> 
  </body>
  </html>请达人指点。。谢谢!~~给分。。

解决方案 »

  1.   

    $content = '<?xml version="1.0" encoding="gb2312" ?> 
    <html author="axgle">
    <head>
    <title>this is title</title> 
    </head>
    <body>
    <p id="1">this is p1</p> 
    <p id="2">this is p2</p> 
    </body>
    </html>';
    $filename = time().'.xml';
    $fp = fopen($filename, 'w');
    fwrite($fp, $content);
    fclose($fp);确保你有对应目录的写入权限先,
      

  2.   

    谢谢!!那如何读取XML文件中的body里的内容并输出????
      

  3.   

    xpath 或者 dom 具体方法网上有O.o
      

  4.   

    用 PHP 读取和编写 XML DOM
    http://www.ibm.com/developerworks/cn/opensource/os-xmldomphp/