【问题标题】:Create output XML file in PHP在 PHP 中创建输出 XML 文件
【发布时间】:2010-11-17 03:36:06
【问题描述】:

如何使用 PHP 创建这种类型的 XML 输出?

<Root>
 <base>  rushi </base>
 <base> stack </base>
 <base> overflow </base>
<root>

【问题讨论】:

标签: php xml dom


【解决方案1】:
【解决方案2】:

这是逐行代码..希望这对您有所帮助

http://code.google.com/apis/maps/articles/phpsqlajax.html

【讨论】:

    【解决方案3】:
    $employees = array(
        '0'=> array(
             'name' =>'abin',
              'age' => '23',
          ),
        '1' => array(
            'name' => 'savin',
            'age'  => '24',
        )
    );
    //$file = fopen('file.xml','w');
    $xml = new SimpleXMLElement('<employees></employees>');
    foreach($employees as $employ):
    $xml->addChild('name',$employ['name']);
    $xml->addChild('age',$employ['age']);
    endforeach;
    file_put_contents('file.xml',$xml->saveXML());
    

    【讨论】:

    • 这一行使rickfile_put_contents('file.xml',$xml->saveXML());
    猜你喜欢
    • 2012-03-24
    • 2019-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-13
    • 2022-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多