I'm having trouble figuring out how to work with xml-js. When I run the code, I see the output. But when I try to get a value from a particular key, it give me either a undefined or cannot read property of undefined error. I added my code below. What am I doing wrong?
var convert = require('xml-js');
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var result2 = convert.xml2json(xml, {compact: true, spaces: 4});
console.log(result2);
Let's say I want the value for title which is 'happy'. I tried doing it this way but it didn't work... result2.title; even tried result2._text; but nothing works. Any help would be appreciated. Thanks!!
result.note.title? As an aside, this chunk of code isn't even close to an minimal reproducible example