XML:insert(name [, text [, attributes [, move]]])
Add a new element to the document as a sibling immediately before the current element.
If text is specified, the element will contain a text node that is set to the value of the text string. The text value can be null.
The optional attributes argument is a table that contains a set of name/value pairs. The table will be used to set the attributes of the new XML element. The attributes value can be null.
The fourth argument is a boolean value. If it is set to true the document position will be set to be the newly created element. Otherwise the document position will not be changed.
Example
doc = xml.parse('<options><host>127.0.0.1</host></options>')
doc:goPath('/options/host')
doc:insert('port','5480')