當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript xml2js.parseString函數代碼示例

本文整理匯總了TypeScript中xml2js.parseString函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript parseString函數的具體用法?TypeScript parseString怎麽用?TypeScript parseString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了parseString函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Promise

    return new Promise((resolve) => {
      let SqliteSyncObject = {
        SyncId: data[0].SyncId,
        TableName: data[0].TableName,
        Records: [],
        QueryInsert: data[0].QueryInsert,
        QueryUpdate: data[0].QueryUpdate,
        QueryDelete: data[0].QueryDelete,
        TriggerInsert: data[0].TriggerInsert,
        TriggerUpdate: data[0].TriggerUpdate,
        TriggerDelete: data[0].TriggerDelete,
        TriggerInsertDrop: data[0].TriggerInsertDrop,
        TriggerUpdateDrop: data[0].TriggerUpdateDrop,
        TriggerDeleteDrop: data[0].TriggerDeleteDrop,
      }

      xml2js.parseString(data[0].Records, function (err, result) {
        if(result && result.records){
          for(let i = 0; i < result.records.r.length; i++){
            let record = {
              Action: result.records.r[i].$.a,
              Columns: []
            };
            for(let ii = 0; ii < result.records.r[i].c.length; ii++){
              record.Columns.push(result.records.r[i].c[ii]);
            }
            SqliteSyncObject.Records.push(record);
          }
          resolve(SqliteSyncObject);
        }
        else{
          resolve(SqliteSyncObject);
        }
      });
    })
開發者ID:sqlite-sync,項目名稱:SQLite-sync.com,代碼行數:35,代碼來源:sqlite-sync.ts

示例2: handleError

 fs.readFile(inputFilePath, (err, data) => {
     handleError(err);
     xml2js.parseString(data.toString(), (err, result) => {
         handleError(err);
         writeFile(outputFilePath, xmlObjectToString(result));
     });
 });
開發者ID:unional,項目名稱:MS-TypeScript,代碼行數:7,代碼來源:generateLocalizedDiagnosticMessages.ts

示例3: containsParamFile

export async  function containsParamFile(webAppPackage: string ) {
    var msDeployPath = await getMSDeployFullPath();
    var msDeployCheckParamFileCmdArgs = "-verb:getParameters -source:package=\"" + webAppPackage + "\"";
    
    var msDeployParamFile = tl.getVariable('System.DefaultWorkingDirectory') + '\\' + 'msDeployParam.bat';
    var parameterFile = tl.getVariable('System.DefaultWorkingDirectory') + '\\' + 'parameter.xml';
    
    var silentCommand = '@echo off \n';
    var msDeployCommand = '"' + msDeployPath + '" ' + msDeployCheckParamFileCmdArgs + " > \"" + parameterFile + "\"";
    var batchCommand = silentCommand + msDeployCommand;

    tl.writeFile(msDeployParamFile, batchCommand);
    tl._writeLine(tl.loc("Runningcommand", msDeployCommand));

    var taskResult = tl.execSync("cmd", ['/C', msDeployParamFile], { failOnStdErr: true, silent: true });
    var paramContentXML = fs.readFileSync(parameterFile);
    var isParamFilePresent = false;
    await parseString(paramContentXML, (error, result) => {
        if(error) {
            throw new Error(error);
        }
        if(result['output']['parameters'][0] ) {
            isParamFilePresent = true;
        }
    });
    tl.debug(tl.loc("Isparameterfilepresentinwebpackage0", isParamFilePresent));
    return isParamFilePresent;
}
開發者ID:HSAR,項目名稱:vso-agent-tasks,代碼行數:28,代碼來源:msdeployutility.ts

示例4: convertXml2js

export function convertXml2js(content: string): JsonObject|null {
  let retResult: JsonObject = null;
  xml2js.parseString(content, (err, result) => {
    retResult = result;
  });
  return retResult;
}
開發者ID:angular,項目名稱:webdriver-manager,代碼行數:7,代碼來源:file_utils.ts

示例5: request

 request(this.options, function (error:any, response:any,body:any) {
     xml2js.parseString(body, function (err:any, result:any) {
         var backData = that._parse(result);
         if(callback){
             callback(backData);
         }
     });
 });
開發者ID:kotcmm,項目名稱:writecnblog,代碼行數:8,代碼來源:xmlrpc.ts

示例6: httpGet

 return httpGet('http://live.bilibili.com/api/playurl', {cid: videoId}).then((xml:string)=> {
         let downloadUrl = null;
         parseString(xml, function (err, result) {
             if (!err && Object.keys(result)) {
                 downloadUrl = result.video.durl[0].url[0]
             }
         });
         return downloadUrl;
     }
開發者ID:xiaopohou,項目名稱:bilibili-live-video-noty,代碼行數:9,代碼來源:link.ts

示例7: parseString

 const translated = await new Promise<string>((resolve, reject) => {      
   parseString(body, (err, result) => {
     if (err) { reject(err) }
     console.log(body + '\n↓ parsing XML to JS object');
     console.log(result);
     console.log('\n');
     resolve(result.string._);
   });
 });
開發者ID:ovrmrw,項目名稱:ms-translator-text-to-text-nodejs,代碼行數:9,代碼來源:translator.ts

示例8: Promise

 return new Promise((resolve, reject) => {
   xml2js.parseString(xml, options || defaultParseOptions, (err, data) => {
     if (err) {
       callback && callback(err);
       return reject(err);
     }
     callback && callback(null, data);
     resolve(data);
   });
 });
開發者ID:hstarorg,項目名稱:wechat-admin,代碼行數:10,代碼來源:xmlHelper.ts

示例9: parseXML

function parseXML(content: string) {
  let xml: Object;
  xml2js.parseString(content, { async: false },(err, result) => {
    if (err) {
      throw err;
    }
    xml = result;
  });
  return xml;
}
開發者ID:pxpeterxu,項目名稱:xar-js,代碼行數:10,代碼來源:create.ts

示例10: resolve

		/**
		 *
		 */
		public resolve(response: CasparCGSocketResponse): Object {
			let parseNumbers = function (str: any) {
				if (!isNaN(str)) {
					str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str)
				}
				return str
			}
			let parseBooleans = function (str: any) {
				if (str === true || str.toString().toLowerCase() === 'true') {
					return true
				} else if (str === false || str.toString().toLowerCase() === 'false') {
					return false
				}
				return str
			}
			let parseLowerCase = function (str: any) {
				return str.toString().toLowerCase()
			}

			let returnFalse: Error | undefined
			let returnData: Object | undefined

			xmlParser(
				response.items[0].replace('\n', ''),
				{ explicitRoot: false, async: false, trim: true, explicitArray: false, mergeAttrs: true, attrValueProcessors: [parseNumbers], valueProcessors: [parseNumbers, parseBooleans], tagNameProcessors: [parseLowerCase], attrNameProcessors: [parseLowerCase] },
				(error, result) => {
					returnFalse = error
					returnData = result
				})

			return returnFalse ? {} : returnData || {}
		}
開發者ID:SuperFlyTV,項目名稱:casparcg-connection,代碼行數:35,代碼來源:ResponseValidators.ts


注:本文中的xml2js.parseString函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。