mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	new-style callback function (xml node)
This commit is contained in:
		| @@ -10,7 +10,7 @@ module.exports = function(RED) { | ||||
|         this.charkey = n.chr; | ||||
|         this.property = n.property||"payload"; | ||||
|         var node = this; | ||||
|         this.on("input", function(msg) { | ||||
|         this.on("input", function(msg,send,done) { | ||||
|             var value = RED.util.getMessageProperty(msg,node.property); | ||||
|             if (value !== undefined) { | ||||
|                 var options; | ||||
| @@ -21,7 +21,8 @@ module.exports = function(RED) { | ||||
|                     var builder = new xml2js.Builder(options); | ||||
|                     value = builder.buildObject(value, options); | ||||
|                     RED.util.setMessageProperty(msg,node.property,value); | ||||
|                     node.send(msg); | ||||
|                     send(msg); | ||||
|                     done(); | ||||
|                 } | ||||
|                 else if (typeof value == "string") { | ||||
|                     options = {}; | ||||
| @@ -30,17 +31,18 @@ module.exports = function(RED) { | ||||
|                     options.attrkey = node.attrkey || options.attrkey || '$'; | ||||
|                     options.charkey = node.charkey || options.charkey || '_'; | ||||
|                     parseString(value, options, function (err, result) { | ||||
|                         if (err) { node.error(err, msg); } | ||||
|                         if (err) { done(err); } | ||||
|                         else { | ||||
|                             value = result; | ||||
|                             RED.util.setMessageProperty(msg,node.property,value); | ||||
|                             node.send(msg); | ||||
|                             send(msg); | ||||
|                             done(); | ||||
|                         } | ||||
|                     }); | ||||
|                 } | ||||
|                 else { node.warn(RED._("xml.errors.xml_js")); } | ||||
|                 else { node.warn(RED._("xml.errors.xml_js")); done(); } | ||||
|             } | ||||
|             else { node.send(msg); } // If no property - just pass it on. | ||||
|             else { send(msg); done(); } // If no property - just pass it on. | ||||
|         }); | ||||
|     } | ||||
|     RED.nodes.registerType("xml",XMLNode); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user