本文整理汇总了TypeScript中xml2js.Parser类的典型用法代码示例。如果您正苦于以下问题:TypeScript Parser类的具体用法?TypeScript Parser怎么用?TypeScript Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parser类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return new Promise<InputTypes.Schedule.ISchedule>((resolve: (schedule: InputTypes.Schedule.ISchedule) => void, reject: (reason: any) => void) => {
const parser: Parser = this.getParser();
parser.parseString(xml, (error: any, parsedXml: InputTypes.Schedule.ISchedule) => {
if (error) {
reject(error);
}
resolve(parsedXml);
});
});
示例2: function
fs.readFile(resxFilename, function(err: any, data: any) {
const parser = new xml2js.Parser();
parser.parseString(data, function (err: any, result: any) {
if (result !== undefined)
{
convertXmlToTypeScriptModelFile(result, resxFilename, typeScriptResourcesNamespace, virtualTypeScriptFolder);
}
});
});
示例3: function
.then(function(xmlContents) {
var parser = new xml2js.Parser();
parser.parseString(xmlContents, function(err, result) {
if (!err && result.RunSettings && result.RunSettings.RunConfiguration && result.RunSettings.RunConfiguration[0] &&
result.RunSettings.RunConfiguration[0].ResultsDirectory && result.RunSettings.RunConfiguration[0].ResultsDirectory[0].length > 0) {
defer.resolve(result.RunSettings.RunConfiguration[0].ResultsDirectory[0]);
}
else {
defer.resolve(defaultResultsDirectory);
}
});
})
示例4: if
.then(function(xmlContents) {
var parser = new xml2js.Parser();
parser.parseString(xmlContents, function(err, result) {
if (err) {
tl.warning("Error occured while reading run settings file. Error : " + err);
tl.debug("Error occured while setting run in parallel. Continuing...");
defer.resolve(settingsFile);
return defer.promise;
}
if (result.RunSettings === undefined) {
tl.warning("Failed to set run in parallel. Invalid run settings file.");
defer.resolve(settingsFile);
return defer.promise;
}
if (!result.RunSettings) {
result.RunSettings = { RunConfiguration: { MaxCpuCount: 0 } };
}
else if (!result.RunSettings.RunConfiguration || !result.RunSettings.RunConfiguration[0]) {
result.RunSettings.RunConfiguration = { MaxCpuCount: 0 };
}
else {
var runConfigArray = result.RunSettings.RunConfiguration[0];
runConfigArray.MaxCpuCount = 0;
}
var builder = new xml2js.Builder();
var runSettingsForParallel = builder.buildObject(result);
saveToFile(runSettingsForParallel)
.then(function(fileName) {
cleanUp(settingsFile);
defer.resolve(fileName);
return defer.promise;
})
.fail(function(err) {
tl.debug("Error occured while setting run in parallel. Continuing...");
tl.warning(err);
defer.resolve(settingsFile);
});
});
})
示例5: if
.then(function (xmlContents) {
var parser = new xml2js.Parser();
parser.parseString(xmlContents, function (err, result) {
if (err) {
tl.warning(tl.loc('ErrorWhileReadingRunSettings', err));
tl.debug(exitErrorMessage);
defer.resolve(settingsFile);
return defer.promise;
}
if (result.RunSettings === undefined) {
tl.warning(tl.loc('FailedToSetRunInParallel'));
defer.resolve(settingsFile);
return defer.promise;
}
if (!result.RunSettings) {
result.RunSettings = { RunConfiguration: { MaxCpuCount: 0 } };
}
else if (!result.RunSettings.RunConfiguration || !result.RunSettings.RunConfiguration[0]) {
result.RunSettings.RunConfiguration = { MaxCpuCount: 0 };
}
else {
var runConfigArray = result.RunSettings.RunConfiguration[0];
runConfigArray.MaxCpuCount = 0;
}
var builder = new xml2js.Builder();
var runSettingsForParallel = builder.buildObject(result);
saveToFile(runSettingsForParallel, runSettingsExt)
.then(function (fileName) {
cleanUp(settingsFile);
defer.resolve(fileName);
return defer.promise;
})
.fail(function (err) {
tl.debug(exitErrorMessage);
tl.warning(err);
defer.resolve(settingsFile);
});
});
})
示例6: function
.then(function (xmlContents) {
var parser = new xml2js.Parser();
parser.parseString(xmlContents, function (err, result) {
if (!err && result.RunSettings && result.RunSettings.RunConfiguration && result.RunSettings.RunConfiguration[0] &&
result.RunSettings.RunConfiguration[0].ResultsDirectory && result.RunSettings.RunConfiguration[0].ResultsDirectory[0].length > 0) {
var resultDirectory = result.RunSettings.RunConfiguration[0].ResultsDirectory[0];
resultDirectory = resultDirectory.trim();
if (resultDirectory) {
// path.resolve will take care if the result directory given in settings files is not absolute.
defer.resolve(path.resolve(path.dirname(runSettingsFile), resultDirectory));
}
else {
defer.resolve(defaultResultsDirectory);
}
}
else {
defer.resolve(defaultResultsDirectory);
}
});
})
示例7:
fs.readFile (file_in,function (err,data)
{
parser.parseString (data,function (err,result)
{
text_manipulate.dict_display_proc (result);
console.log ("*** çľäş ***");
});
});
示例8: CreateSettings
function CreateSettings(runSettingsContents: string) : Q.Promise<any> {
var defer=Q.defer<any>();
parser.parseString(runSettingsContents, function (err, result) {
if(err) {
defer.reject(err);
}
defer.resolve(result);
});
return defer.promise;
}
示例9: errCb
fs.readFile('config.xml', (err: any, data: any) => {
if (err) {
errCb(err);
return;
}
parser.parseString(data, (err: any, result: any) => {
if (err) {
errCb(err);
return;
}
cb(parseConfig(result));
});
});