gockl

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 2 Imported by: 2

README

gockl Build Status GoDoc Coverage Status Go Report Card

gockl is a minimal XML processor for Go that does not to fuck with your markup.

Supported & tested Go versions are: 1.2 – 1.23.

Usage

Transparently decode XML string input and re-encode to string output without affecting the underlying structure of the original file:

buf := bytes.Buffer{}
z := gockl.New(input)

for {
	t, err := z.Next()
	if err != nil {
		break
	}

	if el, ok := t.(gockl.ElementToken); ok {
		log.Println(el.Name())
	}
	buf.WriteString(t.Raw())
}

output := buf.String()
Why?
License

MIT/X11.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name    string
	Content string
}

type CDATAToken

type CDATAToken string

func (CDATAToken) Raw

func (t CDATAToken) Raw() string

type CommentToken

type CommentToken string

func (CommentToken) Raw

func (t CommentToken) Raw() string

type DirectiveToken

type DirectiveToken string

func (DirectiveToken) Raw

func (t DirectiveToken) Raw() string

type ElementToken

type ElementToken interface {
	Token
	Name() string
}

type EmptyElementToken

type EmptyElementToken string

func (EmptyElementToken) Attribute added in v1.1.0

func (t EmptyElementToken) Attribute(name string) (string, bool)

func (EmptyElementToken) Attributes

func (t EmptyElementToken) Attributes() []Attribute

func (EmptyElementToken) Name

func (t EmptyElementToken) Name() string

func (EmptyElementToken) Raw

func (t EmptyElementToken) Raw() string

type EndElementToken

type EndElementToken string

func (EndElementToken) Name

func (t EndElementToken) Name() string

func (EndElementToken) Raw

func (t EndElementToken) Raw() string

type ProcInstToken

type ProcInstToken string

func (ProcInstToken) Raw

func (t ProcInstToken) Raw() string

type StartElementToken

type StartElementToken string

func (StartElementToken) Attribute added in v1.1.0

func (t StartElementToken) Attribute(name string) (string, bool)

func (StartElementToken) Attributes

func (t StartElementToken) Attributes() []Attribute

func (StartElementToken) Name

func (t StartElementToken) Name() string

func (StartElementToken) Raw

func (t StartElementToken) Raw() string

type StartOrEmptyElementToken added in v1.1.0

type StartOrEmptyElementToken interface {
	ElementToken
	Attributes() []Attribute
	Attribute(name string) (string, bool)
}

type TextToken

type TextToken string

func (TextToken) Raw

func (t TextToken) Raw() string

type Token

type Token interface {
	Raw() string
}

type Tokenizer

type Tokenizer struct {
	Input    string
	Position int
}

func New

func New(input string) *Tokenizer

func (*Tokenizer) Next

func (me *Tokenizer) Next() (Token, error)

Jump to

Keyboard shortcuts

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