Using this ootb function, how do I append a new child to my xml ? story node
"use strict";
/**
* @name NL.XML
* @namespace
*/
loadLibrary("/nl/core/shared/nl.js");
loadLibrary("/nl/core/shared/xtk.js");
NL.ns('NL.XML');
NL.require('/nl/core/shared/nl.js').require('/nl/core/shared/xtk.js');
/**
* Append this to a specified node
* @Param {NL.XML} element The element to append this to
* @Returns {NL.XML} this
*/
NL.XML.Node.prototype.appendTo = function (element) {
NL.assert(element instanceof NL.XML.Node,'NL.XML.prototype.appendTo only accepts NL.XML instances as parameters');
element.append(this);
return this;
};
var myXml = <person>
<cards>12345</cards>
<points></points>
</person>
<story>
<line>abc</line>
<test>5</etst>
</story>
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @o_X,
I have not used the appendTo method before, but what you are looking for can be done using the appendChild method, like this:
Let me know if that solves your purpose.
var newXml = <secondLine>new line</secondLine>;
myXml.story.appendChild(newXml);
BR,
Ishan
Hi @o_X,
I have not used the appendTo method before, but what you are looking for can be done using the appendChild method, like this:
Let me know if that solves your purpose.
var newXml = <secondLine>new line</secondLine>;
myXml.story.appendChild(newXml);
BR,
Ishan