如何使用Jstree編輯XML文件?

[英]How to edit an XML file using Jstree?


I'm using Jstree to display an XML file, then using it's capabilities like create and rename to edit the tree displayed, is there is a way to reflect the changes i made in the tree to the original XML file? like when i'm created a node i want that node to be created in the XML file.

我正在使用Jstree顯示XML文件,然后使用它的功能,如創建和重命名來編輯顯示的樹,是否有辦法將我在樹中所做的更改反映到原始XML文件中?就像當我創建一個節點時,我希望在XML文件中創建該節點。

for ex.

if the XML file contains:

如果XML文件包含:

<?xml version="1.0" encoding="UTF-8"?>
<menu parent_id="0" >       
    <ColdDrinks>
            <pepsi  price="5" hasoption = "false"> 
            </pepsi>
            <Mango  price = "8" hasoption = "false">
            </Mango>
            <Water>
            </Water>
    </ColdDrinks>

</menu>

it will be displayed like :

它會顯示如下:

enter image description here

and when i add a new drink :

當我添加新飲料時:

enter image description here

i want my XML file to be edited like that :

我希望我的XML文件編輯如下:

<?xml version="1.0" encoding="UTF-8"?>
<menu parent_id="0" >       
    <ColdDrinks>
            <pepsi  price="5" hasoption = "false"> 
            </pepsi>
            <Mango  price = "8" hasoption = "false">
            </Mango>
            <Water>
            </Water>
    </ColdDrinks>
</menu>

1 个解决方案

#1


0  

You need to use a server side language to edit files on server, like PHP. You can use Ajax technology to pass the changes you make in the xml content, or a string with the xml, to a php script that saves /add data in the xml file.

您需要使用服務器端語言來編輯服務器上的文件,例如PHP。您可以使用Ajax技術將您在xml內容中創建的更改或帶有xml的字符串傳遞給在xml文件中保存/添加數據的php腳本。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/10/08/725262fd3acb71934b43db8f89e18f49.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com