可以在XML中写PHP,你也可以写C,C++,JAVA,C#......
因为XML把它做为数据存起来了呀。问题是,这些只是数据,而不是代码,不可能编译执行的。

解决方案 »

  1.   

    那请问用PHP输出XML要怎么做啊?
      

  2.   

    最简单的方法 lookprint <<<END<?xml version="1.0" encoding="GB2312" ?>
    <root text="ROOT" >
    <menu id="1" text="AAA">
    <menu  id="12" href=""  text="AA"></menu>
    <menu  id="13" href=""  text="BB"></menu>
    <menu  id="14" href=""  text="CC"></menu>
    </menu>
    <menu id="2" text="BBB">
    <menu  id="21" href=""  text="AA"></menu>
    <menu  id="22" href=""  text="BB"></menu>
    <menu  id="23" href=""  text="CC"></menu>
    </menu>
    </root>
    END;
      

  3.   

    楼上的大大的方法不行的啊...在PHP的环境里只会输出一片空白的.
      

  4.   

    这个有点奇怪你的需求到底是什么试试这样吧。
    apache里把.xml文件也作为php文件分析。
    然后直接加php进去,第一行的<?和?>会有歧义,用echo输出试试行否
      

  5.   

    打印出来了呀,我刚试的 代码如下,你的要是是空白,那你看一下IE的源代码,可能是
    <?xml version="1.0" encoding="GB2312" ?>没有在第一行或者<?和xml之间有空格。总之是格式的原因就对了
    <?php
    print <<<END
    <?xml version="1.0" encoding="GB2312" ?>
    <root text="ROOT" >
    <menu id="1" text="AAA">
    <menu  id="12" href=""  text="AA"></menu>
    <menu  id="13" href=""  text="BB"></menu>
    <menu  id="14" href=""  text="CC"></menu>
    </menu>
    <menu id="2" text="BBB">
    <menu  id="21" href=""  text="AA"></menu>
    <menu  id="22" href=""  text="BB"></menu>
    <menu  id="23" href=""  text="CC"></menu>
    </menu>
    </root>
    END;
    ?>
    效果如下:
    <?xml version="1.0" encoding="GB2312" ?> 
    - <root text="ROOT">
    - <menu id="1" text="AAA">
      <menu id="12" href="" text="AA" /> 
      <menu id="13" href="" text="BB" /> 
      <menu id="14" href="" text="CC" /> 
      </menu>
    - <menu id="2" text="BBB">
      <menu id="21" href="" text="AA" /> 
      <menu id="22" href="" text="BB" /> 
      <menu id="23" href="" text="CC" /> 
      </menu>
      </root>