Reordering XML Elements with jquery, then save XML file with php
How can I use something like jQuery & PHP to reorder elements within an xml file?
The jQuery plugins below allow html table rows or list items to be swapped about, but I have no idea of how to save those changes back to an XML file with the click of a button.
www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/
www.jqueryui.com/demos/sortable/
Here it describes a function to Rearrange/Reorder Elements: http://quest4knowledge.wordpress.com/2010/09/04/php-xml-create-add-edit-modify-using-dom-simplexml-xpath/
But that only shows how to swap the position of two elements, not multiple ones. Can they be combined to reorder a longer list of elements?
I'm trying to avoid using mySQL, just php/jquery/xml...
<?xml version="1.0" encoding="utf-8"?>
<gallery>
<p开发者_StackOverflowicture 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>
Thanks Andy.
JS to submit reordered table data:
using: jquery.json-2.2.js
$(document).ready(function() {
$('#table-1').tableDnD();
});
function sendData() {
data = $('#table-1').tableDnDSerialize();
document.dataform.data.value = $.toJSON(data);
return true;
}
Then in PHP to receive data:
$data = json_decode(stripslashes($_POST['data']), true);
$data = rawurldecode($data);
$data = explode("&table-1[]=", $data);
精彩评论