gulp-xml-editor
gulp-xml-editor is a gulp plugin to edit XML document based on libxmljs.
Usage
var xeditor = ; /* edit XML document by using user specific object*/gulp ; /* edit XML document by using user specific object using a namespace*/gulp ; /* edit XML document by using user specific function*/gulp ;
Note
Please see libxmljs wiki page to get more information about libxmljs API.
API
xeditor(editorObjects)
editorObjects
Type: Array of object
The object must be one of following.
// to modify(or add) the text of the elementpath: 'xpath to the element' text: 'new text value' // to modify(or add) a attribute of the elementpath: 'xpath to the element' attr: 'attrName': 'attrValue' // to modify(or add) some attributes of the elementpath: 'xpath to the element' attrs: 'attrName1': 'attrValue1' 'attrName2': 'attrValue2'
You can't specify xpath to attribute nor text node.
xeditor(editorFunction)
editorFunction
Type: function
The editorFunction
must have the following signature: function (xml, [xmljs]) {}
, and must return libxmljs Document object. The xml
argument is libxmljs Document object, and the xmljs
argument is libxmljs object.