xdmp.nodeInsertBefore( sibling as Node, new as Node ) as null
Adds an immediately preceding sibling to a node.
Parameters | |
---|---|
sibling | The sibling node to be preceded by the new node. |
new | The new node to be inserted. |
// create a document declareUpdate(); xdmp.documentInsert("/example.xml", fn.head(xdmp.unquote( '<a><b>bbb</b></a>'))); ****** // add a c node before the b node declareUpdate(); xdmp.nodeInsertBefore(cts.doc("/example.xml").xpath("/a/b"), fn.head(xdmp.unquote('<c>ccc</c>')).root); ****** // look at the new document cts.doc("/example.xml"); => <?xml version="1.0" encoding="UTF-8"?> <a><c>ccc</c><b>bbb</b></a>