xinsert

Usage

xinsert node-type expression [namespace expression] location xpath

Aliases

xadd

Description

Use the expression to create a new node of a given node-type in the location relative to the given xpath.

For element nodes, the format of the expression should look like "<element-name att-name='attvalue' ...>". The < and > characters are optional. If no attributes are used, the expression may simply consist the element name. Note, that in the first case, the quotes are required since the expression contains spaces.

Attribute nodes use the following syntax: "att-name='attvalue' [...]".

For the other types of nodes (text, cdata, comments) the expression should contain the node's literal content. Again, it is necessary to quote all whitespace and special characters as in any expression argument.

The location argument should be one of: after, before, into, replace, append or prepend. See documentation of the location argument type for more detail.

The namespace expression is only valid for elements and attributes and must evaluate to the namespace URI. In that case, the element or attribute name must have a prefix. The created node is associated with a given namespace.

Example 34. Append a new Hobbit element to the list of middle-earth creatures and name him Bilbo.

xsh> xadd element "<creature race='hobbit' manner='good'>" \
  into /middle-earth/creatures
xsh> xadd attribute "name='Bilbo'" \
  into /middle-earth/creatures/creature[@race='hobbit'][last()]

See Also

insert, move, xmove