Parsing XML in Web Workers

匆匆过客 提交于 2019-11-29 02:05:54
Martin Bartlett

Um - answering myself a few hours later - but this may well be a piece of information that proves very useful to people:

There IS an open-source, full function XML parser written entirely in javascript - and it works very well in Web Workers:

XML-JS

Basically, you just need to include tinyxmlsax.js and tinyxmlw3cdom.js in your worker, then follow the doc for using the W3C DOM.

With very little massaging, I got my code to work with both the normal DOMParser (for when running in the foreground) and the xmljs parser.

Obviously its slower - but that really isn't too much of an issue - after all, you're running it in the background!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!