问题
Is there a way to read a file in elm?
I want to have an xml settings file where I will keep different settings and read it with elm (I've seen this parser, but it expects the xml content, not path). I don't want to use ports and these stuff. I need to apply some transformations to this xml because I will have more sets of values (staging and production) and I will need to generate an artefact for each value (I'm using TFS for this).
回答1:
As of today (0.18.0), officially Elm does not support File API and other file-related APIs.
You can perform I/O only through WebSockets or over HTTP.
Anything else is covered by ports.
回答2:
This library provides access to the filereader API. It is only on github because, as it uses native code, it cannot be published on elm-package.
However if you want to use it with xml you might be best using ports anyway, because then you could get javascripts xml parsing too, which will otherwise be a challenge in Elm too.
来源:https://stackoverflow.com/questions/41344662/elm-read-file-content