package koala

import "cuelang.org/go/encoding/xml/koala"

Package koala converts XML to and from CUE, as proposed in https://cuelang.org/discussion/3776.

This encoding is inspired by the BadgerFish convention for translating XML to JSON. XML elements are modeled as CUE structs, their attributes are modeled as struct fields prefixed with "$", and their inner text content is modeleed as a field named "$$".

WARNING: THIS PACKAGE IS EXPERIMENTAL. ITS API MAY CHANGE AT ANY TIME.

Index

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder implements the decoding state.

func NewDecoder

func NewDecoder(fileName string, r io.Reader) *Decoder

NewDecoder creates a decoder from a stream of XML input.

func (*Decoder) Decode

func (dec *Decoder) Decode() (ast.Expr, error)

Decode parses the input stream as XML and converts it to a CUE ast.Expr. The input stream is taken from the Decoder and consumed.

Source Files

decode.go

Version
v0.13.0-alpha.4
Published
Apr 25, 2025
Platform
darwin/amd64
Imports
8 packages
Last checked
14 hours ago

Tools for package owners.