Add "advanced" options to XML parsing node

Allows setting of attrkey and charkey
Push to close #348
This commit is contained in:
Dave C-J
2014-12-15 17:05:18 +00:00
parent 1261bf97ea
commit bf8d549cf7
2 changed files with 34 additions and 2 deletions

View File

@@ -22,6 +22,8 @@ module.exports = function(RED) {
function XMLNode(n) {
RED.nodes.createNode(this,n);
this.attrkey = n.attr || '$';
this.charkey = n.chr || '_';
var node = this;
this.on("input", function(msg) {
if (msg.hasOwnProperty("payload")) {
@@ -30,7 +32,7 @@ module.exports = function(RED) {
node.send(msg);
}
else if (typeof msg.payload == "string") {
parseString(msg.payload, {strict:true,async:true}, function (err, result) {
parseString(msg.payload, {strict:true,async:true,attrkey:node.attrkey,charkey:node.charkey}, function (err, result) {
if (err) { node.error(err); }
else {
msg.payload = result;