welcome/
java-mcmc/
software/
papers/
links/
email me

XML-CP

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXIT STATUS
EXAMPLE
AUTHORS
SEE ALSO

NAME

xml-cp − copy nodes from XML files into an XML file.

SYNOPSIS

xml-cp

[OPTION]... [ [FILE]... [:XPATH]... ]... TARGET[:XPATH]...

DESCRIPTION

xml-cp copies one or more selected nodes from the supplied FILE(s) into the TARGET file. If no FILE is given, then the standard input is read. The nodes are chosen according to the common unified command line convention described in xml-coreutils(7).

The TARGET file is not updated by default, only printed to the standard output with the selected nodes inserted at the first matching XPATH associated with TARGET. To actually write the TARGET file, use the --write-files switch. By default, data is inserted at the first matching XPATH of the TARGET. To insert at all matching XPATH(s) of the TARGET, use the --multi switch.

Several options exist to choose where the copied data should be inserted in TARGET. The default option is --replace.

The precise form of the data being copied depends on the supplied XPATH(s). If the XPATH ends with a slash, data is copied excluding the immediately surrounding tag. If the XPATH ends without a slash, the surrounding tag is also copied. It is best to experiment.

OPTIONS

--write-files

update the TARGET on the filesystem, rather than printing the result to the standard output.

--prepend

the copied nodes are inserted just before the data of the first matching XPATH in TARGET.

--replace

the copied nodes replaces the data of the first matching XPATH in TARGET.

--append

the copied nodes are inserted just after the data of the first matching XPATH in TARGET.

--multi

the copied nodes are inserted at every node that matches some XPATH associated with TARGET.

EXIT STATUS

xml-cp returns 0 on success, or 1 otherwise.

EXAMPLE

Insert matching nodes (incl. children) from all source files as children of the first available matching node of target file:

xml-cp --append *.xml ://secret treasure.xml :/treasure/hidden/

Overwrite a placeholder node completely with an XML data fragment:

xml-cp --write-files data.xml ://customer[3]/ template.xml :/invoice/customer/placeholder

AUTHORS

Laird A. Breyer is the original author of this software. The source code (GPLv3 or later) for the latest version is available at the following locations:
http://www.lbreyer.com/gpl.html
http://xml-coreutils.sourceforge.net

SEE ALSO

xml-coreutils(7)