Application Programming Interface Guide > Built-in Procedures > Procedures Reference > CreateElement
 
CreateElement
Create a child element in an XML document or element. This method creates an element in an XML document or element. The parentXPath expression selects the parent element, relative to root, of the element to create. The namespacePrefixes and namespaceURIs are used to resolve prefixes to namespaces in the parentXPath expression. Each item in namespacePrefixes must have a corresponding item in xpathNamespaces. The empty string is used to specify the default namespace.
Location
/lib/services/
Inputs
root: An XML document or element.
elementName: The fully qualified name of the element. May not be NULL. For example: {http://examples.com/}Example.
position: The position of the element, relative to its siblings. Use 0 to indicate the element should be created before any existing children. Use -1 to indicate that the element should be created after all existing children. The default value is 0.
parentXPath: An XPath expression that is evaluated against the root to identify the parent of the element that is to be created. May not be NULL.
namespacePrefixes: An array of namespace prefixes used in the parentXPath expression. May be NULL.
namespaceURIs: An array of namespace URIs used in the parentXPath expression. May be NULL.
Outputs
envelope: The modified XML document or element.
Exceptions
IllegalArgumentException: If any of the arguments are invalid.
IllegalArgumentException: If the parentXPath expression does not resolve to an element.