本文整理汇总了TypeScript中xml2js.Parser.parseString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Parser.parseString方法的具体用法?TypeScript Parser.parseString怎么用?TypeScript Parser.parseString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml2js.Parser
的用法示例。
在下文中一共展示了Parser.parseString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: readXML
function readXML(file:string){
var parser = new xml2js.Parser();
parser.parseString(file, (err: any, result: any) => {
analyser.getTransactionsXML(result.TransactionList.SupportTransaction);
});
}
示例2: Promise
return new Promise((resolve, reject) => {
xmlParser.parseString(xmlString, (err: Error, result: any) => {
return err ? reject(err) : resolve(result);
});
});
示例3: function
fs.readFile(file_xml, function(err, data) {
console.log ("*** start reading ***");
parser.parseString(data);
});
示例4: updateSettingsFileAsRequired
export async function updateSettingsFileAsRequired(settingsFile: string, isParallelRun: boolean, tiaConfig: models.TiaConfiguration, vsVersion: number, videoCollector: boolean, overrideParametersString: string) : Promise<string>
{
var defer=Q.defer<string>();
var result: any;
if(!isParallelRun && !videoCollector && !tiaConfig.tiaEnabled && !overrideParametersString) {
defer.resolve(settingsFile);
return defer.promise;
}
//Get extension of settings file and contents
var settingsExt = null;
if (settingsFile && fs.lstatSync(settingsFile).isFile() && settingsFile.split('.').pop().toLowerCase() === "testsettings") {
settingsExt=testSettingsExt;
result = await utils.Helper.getXmlContents(settingsFile);
if(!result || result.TestSettings === undefined) {
tl.warning(tl.loc('InvalidSettingsFile', settingsFile));
settingsExt = null;
}
} else if (settingsFile && utils.Helper.pathExistsAsFile(settingsFile)) {
settingsExt = runSettingsExt;
result = await utils.Helper.getXmlContents(settingsFile);
if(!result || result.RunSettings === undefined) {
tl.warning(tl.loc('InvalidSettingsFile', settingsFile));
settingsExt = null;
}
}
if (overrideParametersString) {
if(settingsExt === runSettingsExt) {
result = updateRunSettingsWithParameters(result, overrideParametersString);
} else {
tl.warning(tl.loc('overrideNotSupported'));
}
}
if (isParallelRun) {
if (settingsExt === testSettingsExt) {
tl.warning(tl.loc('RunInParallelNotSupported'));
} else if (settingsExt === runSettingsExt) {
tl.debug("Enabling run in parallel by editing given runsettings.")
result = await setupRunSettingsFileForRunConfig(result, {MaxCpuCount: 0});
} else {
tl.debug("Enabling run in parallel by creating new runsettings.");
settingsExt = runSettingsExt;
result = await CreateSettings(runSettingsForParallel);
}
}
if (videoCollector) {
//Enable video collector only in test settings.
var videoCollectorNode = null;
parser.parseString(VideoDataCollectorTemplate, function(err, data) {
if(err) {
defer.reject(err);
}
videoCollectorNode = data;
});
if (settingsExt === testSettingsExt) {
tl.debug("Enabling video data collector by editing given testsettings.")
result = updateTestSettingsWithDataCollector(result, VideoCollectorFriendlyName, videoCollectorNode);
} else if (settingsExt === runSettingsExt) {
tl.warning(tl.loc('VideoCollectorNotSupportedWithRunSettings'));
} else {
tl.debug("Enabling video data collection by creating new test settings.")
settingsExt = testSettingsExt;
result = await CreateSettings(testSettingsTemplate);
result = updateTestSettingsWithDataCollector(result, VideoCollectorFriendlyName, videoCollectorNode)
}
}
if (tiaConfig.tiaEnabled) {
var testImpactCollectorNode = null;
parser.parseString(TestImpactDataCollectorTemplate, function(err, data) {
if(err) {
defer.reject(err);
}
testImpactCollectorNode = data;
if(tiaConfig.useNewCollector) {
testImpactCollectorNode.DataCollector.$.codebase = getTraceCollectorUri(vsVersion);
}
testImpactCollectorNode.DataCollector.Configuration[0].ImpactLevel = getTIALevel(tiaConfig);
if (getTIALevel(tiaConfig) === 'file') {
testImpactCollectorNode.DataCollector.Configuration[0].LogFilePath = 'true';
}
if (tiaConfig.context === "CD") {
testImpactCollectorNode.DataCollector.Configuration[0].RootPath = "";
} else {
testImpactCollectorNode.DataCollector.Configuration[0].RootPath = tiaConfig.sourcesDir;
}
});
//var baseLineBuildId = await utilities.readFileContents(tiaConfig.baseLineBuildIdFile, "utf-8");
if(settingsExt === testSettingsExt)
{
tl.debug("Enabling Test Impact collector by editing given testsettings.")
result = updateTestSettingsWithDataCollector(result, TestImpactFriendlyName, testImpactCollectorNode);
//result = await setupTestSettingsFileForRunConfig(result, { TestImpact : { '$': {enabled: 'true'} }, BaseLineRunId : baseLineBuildId});
} else if (settingsExt === runSettingsExt) {
tl.debug("Enabling Test Impact collector by editing given runsettings.")
//.........这里部分代码省略.........
示例5: parseString
parseString(str: string , cb?: Function) {
this.parser.parseString(str, cb);
}