How do you parse XML in Elm?
Elm has no built-in XML parser — the standard library covers JSON via Json.Decode but not XML. The community choice is jinjor/elm-xml-parser which exposes XmlParser.parse : String -> Result Error Xml and a Node ADT (Element name attrs children | Text str). For SOAP-heavy projects, eeue56/elm-xml-decode adds combinators inspired by elm/json. The generator produces records that fit both patterns.
How are XML attributes mapped to Elm record fields?
Attribute fields are suffixed with "Attr" — e.g. <book id="bk101"> becomes idAttr : String — to disambiguate from a sibling child element that might share the name. When you write the XmlParser decoder, you read attributes from the Element constructor (the List Attribute) — second argument (the List Attribute) rather than walking children.
Why is Elm strict about decoders?
Elm has no exception system — every parser failure is a Result Error a value the call site must handle. This makes XML parsing verbose but catastrophically robust: malformed XML or missing fields cannot crash the runtime, they can only produce a Result.Err. The generated record type is the success-side payload; you write the matching decoder to populate it.
Are records the right Elm shape for XML?
Yes — XML elements are inherently structural (a fixed bag of attributes plus children) which matches Elm records perfectly. Custom union types are reserved for genuinely sum-typed XML (e.g. <message>...</message> | <error>...</error>). The generator always emits records; refactor to a union type only when your XML schema exposes alternatives.
How are repeated elements like <tag> typed?
Repeated child elements become List T fields — Elm lists are immutable and ordered, matching XML element ordering. The generator infers T from the first occurrence; if your real data has heterogeneous shapes across instances, define a custom union type and refine the decoder manually.
Does the generator emit a working decoder?
No — it emits the type aliases only, with the elm-xml-parser import scaffold in place. Writing the decoder is the next step: walk the Xml ADT in xmlToBook : Xml -> Result String Book, picking attributes from the Element constructor — its attribute list and recursing into children. The generated record gives you the target shape; the decoder is yours to write.
Is the XML I paste sent to your servers?
No. XML is parsed by the browser DOMParser and the Elm source is generated entirely in JavaScript on your machine. Open DevTools → Network and you will see no requests when you click Convert. Safe for SOAP responses and configuration files containing API keys or credentials.
Why no Maybe wrappers in the output?
Optional-vs-required is a domain decision the generator cannot infer from a single sample. Wrap any field that may be missing in Maybe yourself: title : Maybe String — the decoder would then return Nothing when the XML lacks that element. The generator stays neutral so you do not over-Maybe types that turn out to be required in production.