# gleam_xml2map
**Repository Path**: mirrors_floatdrop/gleam_xml2map
## Basic Information
- **Project Name**: gleam_xml2map
- **Description**: Parse XML to objects with gleam/decode
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-09-22
- **Last Updated**: 2026-05-09
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# xml2map
[](https://hex.pm/packages/xml2map)
[](https://hexdocs.pm/xml2map/)
```sh
gleam add xml2map@1
```
```gleam
import gleam/dynamic/decode
import gleam/list
import gleam/result.{try}
import xml2map
pub type Node {
Node(children: List(Child))
}
pub fn node_decoder() -> decode.Decoder(Node) {
// Decode one child or multiple child to List
use children <- decode.field(
"child",
decode.one_of(decode.list(child_decoder()), or: [
child_decoder() |> decode.map(list.wrap),
]),
)
decode.success(Node(children:))
}
pub type Child {
Child(name: String, text: String)
}
pub fn child_decoder() -> decode.Decoder(Child) {
use name <- decode.field("@name", decode.string)
use text <- decode.field("#text", decode.string)
decode.success(Child(name:, text:))
}
pub fn main() -> Nil {
use node <- try(xml2map.parse("text1text2", using: node_decoder()))
let _ = echo node
}
```
Further documentation can be found at .
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
```