dsxrq28228 2016-11-22 01:20
浏览 12
已采纳

使用domdocument在两个XML元素内部编写

So I'm creating a register script with XML. You can log in fine but I am having trouble with the registering part. Here is my attempt at registration:

<?
    session_start();
    $w = new DOMDocument();
    $w->formatOutput = true;
    $r = $w->createElement("accounts");
    $w->appendChild($r);
    $b = $w->createElement("account");
    $username = $w->createElement("username");
    $username-> /* ??? */

    $password = $w->createElement("password");
    $password-> /* ??? */   

    // ...
?>

and here is the XML dummy that I want to create:

<accounts>
    <account>
        <username>foo</username>
        <password>foo</password>
        <email>foo</email>
        <ip>foo</ip>
        <balance>700</balance>
    </account>
</accounts>
  • 写回答

1条回答 默认 最新

  • dongzi5673 2016-11-22 01:30
    关注

    http://php.net/manual/en/domdocument.createelement.php

    $w->createElement('username','foo');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”