I'm looking into functional-programming ways to write a simple web app that does XSLT-like things. I'm thinking about trying Purescript, but I need to make sure it's possible (and relatively easy) to parse XML using it. Is there a way to do that? I found purescript-xml but it seems to be dead (no longer on Pursuit). Am I missing something?
I made a simple foreign import for DOMParser and then used the standard DOM library purescript-dom.
There are bindings in purescript-domparser but I didn't care for them. There is no reason I can discern for representing the DOMParser object.
This is what I used:
exports.parseXML = function (s) {
return new DOMParser().parseFromString(s, 'application/xml');
}
foreign import parseXML :: String -> Document
Unfortunately, DOMParser does not make it straight-forward to determine if parsing failed. On failure, it still returns a valid Document but only contains information about the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With