Skip to content Skip to sidebar Skip to footer

Parsing Xml In A Web Worker

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.ELEMENT_

Solution 1:

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"

Solution 2:

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

Post a Comment for "Parsing Xml In A Web Worker"