I am trying to manipulate an xml file sitting on a server utilizing node-elementtree in a nodejs app... I have had no problems writing to the file and saving it on the server but am completely baffled on how to remove an element.
I'm reading in the file and successfully locating the element that I want to remove from the doc before saving:
fs.readFile(coursePath, function(err, data){
var XML = et.XML;
var ElementTree = et.ElementTree;
var element = et.Element;
var subElement = et.SubElement;
var _data, etree;
_data = data.toString();
etree = et.parse(_data);
var stringID = content.id.toString();
console.log(etree.find('./item/[@id="'+stringID+'"]'));
var myitem = etree.find('./item/[@id="'+stringID+'"]');
But, when I try to remove it:
etree.remove(myitem);
I get the following error:
[TypeError: undefined is not a function]
TypeError: undefined is not a function
at /Users/xxxxxxx/Sites/xxxxxx/bin/server/xxxxxxx-socket-handler.js:915:19
at fs.js:291:14
at Object.oncomplete (fs.js:97:15)
The docs are kind of sparse and I've been banging my head off of something that I thought would be fairly simple, for hours - any advice would be greatly appreciated.
Best, Phil