作者:Blackn | 来源:互联网 | 2023-05-17 18:05
HeyIamusinghtmlparser2toparsethexml.followingismycode嘿我正在使用htmlparser2来解析xml。以下是我的代码v
Hey I am using htmlparser2 to parse the xml. following is my code
嘿我正在使用htmlparser2来解析xml。以下是我的代码
var htmlparser = require('htmlparser2');
var fs = require('fs');
var sitemapUrls = [];
var parser = new htmlparser.Parser({
ontext: function(text){
if(text.match(/foo/)){
sitemapUrls.push(text);
}
}
});
fs.createReadStream('./sitemap-index.xml').pipe(parser).on('end',function(){
console.log(sitemapUrls.length);
});
I am not able find whether do we have any event for htmlparser2 which tells us the parsing is completed.
我无法找到是否有任何htmlparser2事件告诉我们解析完成。
I want to print the length of sitemapUrls array .
我想打印sitemapUrls数组的长度。
Thanks In Advance
提前致谢
1 个解决方案