当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript xml2js.Parser类代码示例

本文整理汇总了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);
			});
		});
开发者ID:CUMTD,项目名称:WebScheduleGenerator,代码行数:9,代码来源:xml-parser.ts

示例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);                       
                 }
            });  
        });    
开发者ID:mvdcorput,项目名称:node-resx-to-typescript,代码行数:10,代码来源:index.ts

示例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);
         }
     });
 })
开发者ID:Alekseypv,项目名称:vsts-tasks,代码行数:12,代码来源:vstest.ts

示例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);
                            });
                    });
                })
开发者ID:Alekseypv,项目名称:vsts-tasks,代码行数:42,代码来源:vstest.ts

示例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);
                            });
                    });
                })
开发者ID:ColinDabritz,项目名称:vsts-tasks,代码行数:42,代码来源:vstest.ts

示例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);
                }
            });
        })
开发者ID:ColinDabritz,项目名称:vsts-tasks,代码行数:21,代码来源:vstest.ts

示例7:

fs.readFile (file_in,function (err,data)
	{
	parser.parseString (data,function (err,result)
		{
		text_manipulate.dict_display_proc (result);
		console.log ("*** 終了 ***");
		});
	});
开发者ID:ekzemplaro,项目名称:data_base_language,代码行数:8,代码来源:xml_read.ts

示例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; 
}
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:10,代码来源:settingshelper.ts

示例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));
   });
 });
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:13,代码来源:cordova-config.ts


注:本文中的xml2js.Parser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。