var SomeObject = xmlDoc2.get('Objects').childNodes();
SomeObject.forEach(function (child) {
var theId = child.attr('id');
if (theId !== null) {
var theIdVal = theId.value();
console.log('Id: ' + theIdVal);
app.get('/obj/:id', function (req, res) {
if (req.params.id == theIdVal) {
res.json('This is id: ' + theIdVal);
console.log('This is id: ' + theIdVal)
}
else {
}
})
}
});
The problem is that I cen only get /obj/first --> first element's id url. If I type "Two" itg just keep loading the page, without a result. ( and lets say xml looks like this:)
<Objects>
<Object id="First">
</Object>
<Object id="Two">
</Object>
<Object id="Three">
</Object>
</Objects>