[w3c/DOM-Parsing] Proposal: add a method in DOMParser for parsing non-UTF8 XML documents (#18)

I'm not sure whether this is the correct place for requesting changes to the standard or not. If not please give me a direction.

The story starts from a rejected proposal at whatwg/fetch#16. With the new Fetch API, programmars need to parse XML streams by themselves. However, current ```DOMParser.parseFromString``` supports UTF-8 XML documents only. [1] The result is that there's no way to handle non-UTF8 XML documents correctly with Fetch API. I propose to add a new method that accepts typed arrays. Mozilla's private API ```DOMParser.parseFromBuffer``` looks promising. [2] With that I can do this:

```Javascript
fetch(xml_url).then(function (res) {
    res.arrayBuffer().then(function (buffer) {
        var parser = new DOMParser();
        var view = new Uint8Array(buffer);
        console.log(parser.parseFromBuffer(view, view.length, 'text/xml'));
    });
});
```

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1287071
[2] https://dxr.mozilla.org/mozilla-central/source/dom/webidl/DOMParser.webidl

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/DOM-Parsing/issues/18

Received on Friday, 15 July 2016 15:33:55 UTC