xqml

package module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRootTag    = "root"
	DefaultElementTag = "element"
)
View Source
const (
	ContentNone = iota
	ContentValue
	ContentObject
)

Variables

This section is empty.

Functions

func Stringify

func Stringify(v any) string

func ToJson added in v0.0.6

func ToJson(b []byte) (map[string]any, error)

Types

type Decoder added in v0.0.8

type Decoder struct {
	// Attributes allows to keep attributes. Default is true.
	Attributes bool
	// Namespaces allows to keep namespaces. Default is true.
	Namespaces bool
	// ForceList allows to force some elements to be parsed as slices, even when only one element is present.
	// Supports "r.x" paths notation and "x" element names. Multiple values can be passed as comma separated values, like "r.x,r.y,z".
	ForceList []string
	// Html allows HTML content, by auto-closing known HTML tags. Default is false.
	Html bool
	// Partials allow to call Decode() multiple times to return multiple XML files. When true, Decode() can be called until io.EOF is reached. Default is false.
	Partials bool
	// Cast allows to cast values to boolean/int/float. Default is true.
	Cast bool
	// Sep allows to set text separator between multiple CDATA. Default is " ".
	Sep string
	// contains filtered or unexported fields
}

func NewDecoder added in v0.0.8

func NewDecoder(reader io.Reader) *Decoder

NewDecoder returns a new decoder that reads from r.

The decoder introduces its own buffering and may read data from r beyond the XML values requested.

func (*Decoder) Decode added in v0.0.8

func (x *Decoder) Decode(v any) error

Decode reads the next XML-encoded value from its input and stores it in the value pointed to by v.

See the documentation for Unmarshal for details about the conversion of XML into a Go value.

type Encoder added in v0.0.8

type Encoder struct {
	// Indent allows to set output indentation. Default is "".
	Indent string
	// Root allows to set root element name. Default is "root".
	Root string
	// Element allows to set root.element element name. Default is "element".
	Element string
	// contains filtered or unexported fields
}

func NewEncoder added in v0.0.8

func NewEncoder(writer io.Writer) *Encoder

NewEncoder returns a new encoder that writes to w. The Encoder should be closed after use to flush all data to w.

func (*Encoder) Encode added in v0.0.8

func (x *Encoder) Encode(value any) error

Encode writes the XML encoding of v to the stream.

See the documentation for Marshal for details about the conversion of Go values to XML.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL