【发布时间】:2010-10-28 15:42:26
【问题描述】:
如何使用 jQuery 和 PHP 之类的东西对 xml 文件中的元素重新排序?
下面的 jQuery 插件允许交换 html 表格行或列表项,但我不知道如何通过单击按钮将这些更改保存回 XML 文件。
www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/
www.jqueryui.com/demos/sortable/
这里描述了一个重新排列/重新排序元素的函数: http://quest4knowledge.wordpress.com/2010/09/04/php-xml-create-add-edit-modify-using-dom-simplexml-xpath/
但这仅显示如何交换两个元素的位置,而不是多个元素。 可以将它们组合起来重新排序更长的元素列表吗?
我试图避免使用 mySQL,只使用 php/jquery/xml...
<?xml version="1.0" encoding="utf-8"?>
<gallery>
<picture id="0001">
<title>Title One</title>
<description>Some text here</description>
</picture>
<picture id="0002">
<title>Title Two</title>
<description>Some more text here</description>
</picture>
<picture id="0003">
<title>Title Three</title>
<description>Some other text here</description>
</picture>
</gallery>
谢谢安迪。
【问题讨论】: