如何使用php创建xml文件

时间:2014-12-26 05:16:45

标签: php

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

当用户以xml格式保存数据时所有数据存储。

所以,请给我解决方案。

1 个答案:

答案 0 :(得分:0)

  

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

&#39);             $ node-> addChild(' content',$ text);             $ xml = $ node-> asXML();             file_put_contents(' sample.xml',$ xml);         }        $ xml = simplexml_load_file(' sample.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>
  • 以上代码是一个示例,但您可以按照自己的方式使用
  • 如果对此答案有任何疑问,请评论我......:)