Parsing XML in a Web Worker

前端 未结 2 715
时光取名叫无心
时光取名叫无心 2020-12-19 05:59

I have been using a DOMParser object to parse a text string to an XML tree. However it is not available in the context of a Web Worker (and neither is, of course, document.E

相关标签:
2条回答
  • 2020-12-19 06:28

    according to the spec

    The DOM APIs (Node objects, Document objects, etc) are not available to workers in this version of this specification.

    I guess thats why DOMParser is not availlable, but I don't really understand why that decision was made. (fetching and processing an XML document in a WebWorker does not seems unreasonnable)

    but you can import other tools available: a "Cross Platform XML Parsing in JavaScript"

    0 讨论(0)
  • 2020-12-19 06:43

    At this point I like to share my parser: https://github.com/tobiasnickel/tXml

    with its tXml() method you can parse a string into an object and it takes only 0.5kb minified + gzipped

    0 讨论(0)
提交回复
热议问题