I need help on running javascript code through NodeJS. So far I have the following code;
txt="<bookstore><book>";
txt=txt+"<title>Everyday Italian</title>";
txt=txt+"<author>Giada De Laurentiis</author>";
txt=txt+"<year>2005</year>";
txt=txt+"</book></bookstore>";
parser=new DOMParser();
xmlDoc=parser.parseFromString(txt,"text/xml");
x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
x.nodeValue="Diffrent Title";
I have it as test.js and I run it in the commant prompt as
node test.js
But it gives the following error:
ReferenceError: DOMParser is not defined
What as I doing wrong here. Can any one help please.