Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res.on('end', function () {
var xmlDoc = libxmljs.parseXmlString(xml);
/* eg: leaf[@name="FBX: France 2 HD (TNT)"]/@id' */
var res = xmlDoc.get("//leaf[@name=\"" + channel + "\"]");
if (!res) {
console.log("VLC_GET_CHANID: " + channel + " not found !");
cb("VLC Channel not found in playlist");
} else {
var id = res.attr("id").value();
console.log("VLC_GET_CHANID: " + id);
cb(null, { id: id });
}
});
});
}).toXML(function(err, data){
if ( err ) { return done(err); }
var xmlDoc = libxmljs.parseXmlString(data);
var xpath = "//MaxScaleDenominator";
var x = xmlDoc.get(xpath);
assert.ok(x, "Xpath '" + xpath + "' does not match " + xmlDoc);
assert.equal(x.text(), "50000000");
done();
});
});
.toXML(function(err, data){
if ( err ) { return done(err); }
var xmlDoc = libxmljs.parseXmlString(data);
var color = xmlDoc.get("//@fill");
assert.equal(color.value(), "#000000");
done();
});
});
.then(xmlData => {
try {
projectData = parseXmlString(xmlData);
} catch (err) {
return Promise.reject(new util.DataInvalid('Failed to parse project file.'))
}
const modDataPath = projectData.get('//ModDataPath');
modDataPath.text(modPath);
return fs.writeFileAsync(projectFilePath, projectData.toString(), { encoding: 'utf-8' });
})
}
.then(xmlData => {
try {
modInfo = parseXmlString(xmlData);
const modName = modInfo.get('//Name');
return ((modName !== undefined) && (modName.attr('value').value() !== undefined))
? Promise.resolve(modName.attr('value').value())
: Promise.reject(new util.DataInvalid('Unexpected modinfo.xml format'));
} catch (err) {
return Promise.reject(new util.DataInvalid('Failed to parse ModInfo.xml file'))
}
})
}