change Position of a Node
Brought to you by:
bs_php,
nigelswinson
|
From: J. C. <jan...@im...> - 2004-07-21 13:26:44
|
Can anyone show me a smart way to move a complete node-structure up or down
in the xml document?
$xml="<root><A>abc</A><B>def</B></root>";
...
move("/root/B[1]","up");
echo $xml; //should give: <root><B>def</B><A>abc</A></root>
move("/root/B[1]","down");
echo $xml; //should give: <root><A>abc</A><B>def</B></root>
function move($xpath,$direction){
global $XPathObject;
//???
}
I am thinking about deleting and re-inserting all the nodes in the parent
node but there must be an easy way, or not? Can I just change the two index
keys in the xpath array?
Has anyone coded something for this problem before?
Thanks for any help!
Cheers
Jan
|