mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add "advanced" options to XML parsing node
Allows setting of attrkey and charkey Push to close #348
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user