xmove [--respective|:r] [--preserve-order|:p] xpath location xpath




Like xcopy, except that xmove removes the source nodes after a successful copy. Remember that the moved nodes are actually different nodes from the original ones (which may not be obvious when moving nodes within a single document into locations that do not require type conversion). So, after the move, the original nodes don't belong to any document and are automatically destroyed unless still contained in some variable.

This command returns a node-list consisting of all nodes it created on the target locations.

If --respective|:r option is used, then the target node-list expression is evaluated in the context of the source node being copied.

The --preserve-order|:p option can be used to ensure that the copied nodes are in the same relative order as the corresponding source nodes. Otherwise, if location is after or prepend, the relative order of the copied nodes will be reversed, because source nodes are placed to the target location one by one.

See xcopy for more details on how the copies of the moved nodes are created.

The following example demonstrates how xmove can be used to get rid of HTML <font> elements while preserving their content. As an exercise, try to figure out why simple foreach //font { xmove node() replace . } would not work here.

Example 60. Get rid of all <font> tags

while //font {
  foreach //font {
    xmove node() replace .;

See Also

move, copy, xcopy, insert, xinsert