如何使用 php 创建 xml 文件


How to create xml files using php

我正在用php创建一个简单的Web应用程序。

当用户将数据保存在表单中时,所有数据存储都以XML格式。

所以,请给我解决方案。

如果你谷歌搜索比也满足答案,但也检查下面的代码

'); $node->addChild('content', $text); $xml = $node->asXML(); file_put_contents("样品.xml", $xml); } $xml = simplexml_load_file('样本.xml'); $text = htmlspecialchars($xml->content); ?>
<html>
    <head>
        <title>HTML data: Storing in XML, editing with CKEditor</title>
        <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    </head>
    <body>
        <!-- Our page editing form -->
        <form action="" method="post">
            <textarea name="editor1">
                <?php
                    // Echo our escaped HTML data into the textarea.
                    echo $text;
                ?>
            </textarea>
            <input type="submit" value="Submit">
        </form>
        <script>
            // Add CKEditor to textarea with name 'editor1'.
            CKEDITOR.replace( "editor1" );
        </script>
    </body>
</html>
  • 上面的代码是一个示例,但您可以按照自己的方式使用
  • 如果这个答案有任何问题,请评论我...:)