duanpo7282 2014-06-30 15:12
浏览 99

PHP通过表单将动态内容添加到XML文件

<Country id="USA" value="USA">
    <cities>
        <city link="">city1</subissue>
        <city link="">city2</subissue>

    </subissues>
</Country>
<Country id="UK" value="uk">
    <cities>
        <city link="">city3</subissue>
        <city link="">city4</subissue>
    </cities>
</Country>

I was wondering how I would be able to append, edit and delete information from the XML while it is on the server. I was thinking about using PHP for this. for example I want to add a new city under the USA or add a new country all together and add cities underneath that new country i just added. I was thinking about using a form to add the information. What would be the best approach to add cities to existing countries, add a new country with new cities option or delete a country or delete certain options. Is it possible that someone can also lay down how the form should be conceptually. thank you

  • 写回答

1条回答 默认 最新

  • douqiang3768 2014-06-30 16:45
    关注

    The best way to do this would be to use a database (such as mysql or SQLITE) and generate the xml file upon request.

    Then, in order to add a country or a city, all you would need to do would be a simple insert statement such as:

    INSERT INTO locations VALUES('$country','$city');
    

    And then have a php file with:

    header("Content-Type:text/xml");
    

    and then simply echo the xml data from the database.

    评论

报告相同问题?

悬赏问题

  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!