In Elm, how do I parse an XML file? I see lots of example for JSON decoders, but I cannot find an XML decoder.

What alternatives do I have besides REGEX? My XML is pretty simple, and that would work, but I know that's a bad idea.

  • 3
    I would suggest using a port and a JS library. Not very idiomatic but you'll probably get a result much quicker – Simon H Oct 18 '16 at 9:58
  • I second to @SimonH as I'm not aware of any library to help you parse XML. In javascript, there are some known ones available. – Tosh Oct 18 '16 at 14:46
  • I ended up sending my XML to a port, and then using DOMParser and Xpath to get the fields out of the XML that I was interested in. – jm. Oct 22 '16 at 20:39
  • Hey @jm, what about this: package.elm-lang.org/packages/eeue56/elm-xml/latest ? – Franzé Jr. Jul 1 '17 at 1:04
  • @franzé-jr should put that as an answer instead of a comment. – jm. Jul 1 '17 at 13:41
up vote 2 down vote accepted

This is pretty new:

http://package.elm-lang.org/packages/eeue56/elm-xml/latest

It seems the commit is from this year(2017). I think this is what you're looking for!

Now apparently there is no package for XML parsing. But maybe you are interested in this project:

https://github.com/toburger/elm-xml-parser

  • Thinking about it. – jm. Oct 20 '16 at 15:56

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.