• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript xmldom.DOMParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中xmldom.DOMParser的典型用法代码示例。如果您正苦于以下问题:TypeScript DOMParser类的具体用法?TypeScript DOMParser怎么用?TypeScript DOMParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DOMParser类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: parseXML

export function parseXML(value:string){
    var v=new DomParser.DOMParser(parserOptions);
    if (!value || value.trim().indexOf("<<") == 0) return null;

    var parsed=v.parseFromString(value);
    return cleanupJson(cleanupText(xmlToJson(parsed)))
}
开发者ID:wux5,项目名称:raml-js-parser-2,代码行数:7,代码来源:xmlutil.ts


示例2: parseResponse

function parseResponse(response: Buffer): XMLDocument {
    const xml = iconv.decode(response, ENCODING);
    const parser = new DOMParser();
    const document = parser.parseFromString(xml, 'application/xml');
    return document;
}
开发者ID:lshain,项目名称:vscode-php-debug,代码行数:6,代码来源:dbgp.ts


示例3: _handleDataChunk

 private _handleDataChunk(data: Buffer) {
     // Anatomy of packets: [data length] [NULL] [xml] [NULL]
     // are we waiting for the data length or for the response?
     if (this._parsingState === ParsingState.DataLength) {
         // does data contain a NULL byte?
         const nullByteIndex = data.indexOf(0);
         if (nullByteIndex !== -1) {
             // YES -> we received the data length and are ready to receive the response
             this._dataLength = parseInt(iconv.decode(data.slice(0, nullByteIndex), ENCODING));
             // reset buffered chunks
             this._chunks = [];
             this._chunksDataLength = 0;
             // switch to response parsing state
             this._parsingState = ParsingState.Response;
             // if data contains more info (except the NULL byte)
             if (data.length > nullByteIndex + 1) {
                 // handle the rest of the packet as part of the response
                 const rest = data.slice(nullByteIndex + 1);
                 this._handleDataChunk(rest);
             }
         } else {
             // NO -> this is only part of the data length. We wait for the next data event
             this._chunks.push(data);
             this._chunksDataLength += data.length;
         }
     } else if (this._parsingState === ParsingState.Response) {
         // does the new data together with the buffered data add up to the data length?
         if (this._chunksDataLength + data.length >= this._dataLength) {
             // YES -> we received the whole response
             // append the last piece of the response
             const lastResponsePiece = data.slice(0, this._dataLength - this._chunksDataLength);
             this._chunks.push(lastResponsePiece);
             this._chunksDataLength += data.length;
             const response = Buffer.concat(this._chunks, this._chunksDataLength);
             // call response handler
             const xml = iconv.decode(response, ENCODING);
             const parser = new DOMParser({
                 errorHandler: {
                     warning: warning => {
                         // ignore
                     },
                     error: error => {
                         this.emit('error', error);
                     },
                     fatalError: error => {
                         this.emit('error', error);
                     }
                 }
             });
             const document = parser.parseFromString(xml, 'application/xml');
             this.handleResponse(document);
             // reset buffer
             this._chunks = [];
             this._chunksDataLength = 0;
             // switch to data length parsing state
             this._parsingState = ParsingState.DataLength;
             // if data contains more info (except the NULL byte)
             if (data.length > lastResponsePiece.length + 1) {
                 // handle the rest of the packet (after the NULL byte) as data length
                 const rest = data.slice(lastResponsePiece.length + 1);
                 this._handleDataChunk(rest);
             }
         } else {
             // NO -> this is not the whole response yet. We buffer it and wait for the next data event.
             this._chunks.push(data);
             this._chunksDataLength += data.length;
         }
     }
 }
开发者ID:ullychan,项目名称:vscode-php-debug,代码行数:69,代码来源:dbgp.ts


示例4: loadDOM

 async loadDOM(uri: string, options: Options = {}) {
     const body = await this.load(uri);
     const parser = new DOMParser(options);
     return parser.parseFromString(body, 'text/xml');
 }
开发者ID:chasidic,项目名称:scraper,代码行数:5,代码来源:Scraper.ts


示例5: XPathTransformer

export function XPathTransformer(resp) {
    let doc = dom.parseFromString(resp.rawBody);
    return Q.resolve().then(() => {
        return (path) => {
            return xpath.select(path, doc);
        };
    });
}
开发者ID:njenan,项目名称:turbulence,代码行数:8,代码来源:XPathTransformer.ts


示例6:

		.then(res => {
			const xml = parser.parseFromString(res.data);
			const pods = xpath.select('//pod[contains(@title, "Result")]/subpod/plaintext', xml)
			if(pods.length == 0)
				return false;

			return { text: pods[0].firstChild.data, send: true };
		})
开发者ID:taimur38,项目名称:toombot,代码行数:8,代码来源:wolfram.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript xmlhttprequest.XMLHttpRequest类代码示例发布时间:2022-05-25
下一篇:
TypeScript xmlbuilder.create函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap