當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。