xixo

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SimpleQuote  = "'"
	DoubleQuotes = "\""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name  string
	Value string
	Quote Quote
}

func (Attribute) String added in v0.1.6

func (attr Attribute) String() string

type Callback

type Callback func(*XMLElement) (*XMLElement, error)

func XMLElementToJSONCallback

func XMLElementToJSONCallback(callback CallbackJSON) Callback

func XMLElementToMapCallback

func XMLElementToMapCallback(callback CallbackMap) Callback

XMLElementToMapCallback transforms an XML element into a map, applies a callback function, adds parent attributes, and updates child elements.

type CallbackJSON

type CallbackJSON func(string) (string, error)

type CallbackMap

type CallbackMap func(map[string]string) (map[string]string, error)

type Driver

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

Driver represents a driver that processes XML using callback functions.

func NewDriver

func NewDriver(reader io.Reader, writer io.Writer, callbacks map[string]CallbackMap) Driver

NewDriver creates a new FuncDriver instance with the given reader, writer, and callbacks.

func (Driver) Stream

func (d Driver) Stream() error

Stream processes the XML using registered callback functions and returns any error encountered.

type Quote added in v0.1.6

type Quote string

func ParseQuoteType added in v0.1.6

func ParseQuoteType(car byte) Quote

type XMLElement

type XMLElement struct {
	Name      string
	Attrs     map[string]Attribute
	AttrKeys  []string
	InnerText string
	Childs    map[string][]XMLElement
	Err       error
	// contains filtered or unexported fields
}

func NewXMLElement

func NewXMLElement() *XMLElement

func (*XMLElement) AddAttribute

func (n *XMLElement) AddAttribute(attr Attribute)

func (*XMLElement) FirstChild

func (n *XMLElement) FirstChild() *XMLElement

func (*XMLElement) NextSibling

func (n *XMLElement) NextSibling() *XMLElement

func (*XMLElement) RemoveAttribute added in v0.1.8

func (n *XMLElement) RemoveAttribute(name string)

func (*XMLElement) RemoveChild added in v0.1.8

func (n *XMLElement) RemoveChild(name string)

func (*XMLElement) String

func (n *XMLElement) String() string

type XMLParser

type XMLParser struct {
	TotalReadSize uint64
	// contains filtered or unexported fields
}

func NewXMLParser

func NewXMLParser(reader io.Reader, writer io.Writer) *XMLParser

func (*XMLParser) EnableXpath

func (x *XMLParser) EnableXpath() *XMLParser

func (*XMLParser) ParseAttributesOnly

func (x *XMLParser) ParseAttributesOnly(loopElements ...string) *XMLParser

func (*XMLParser) RegisterCallback

func (x *XMLParser) RegisterCallback(match string, callback Callback)

func (*XMLParser) RegisterJSONCallback

func (x *XMLParser) RegisterJSONCallback(match string, callback CallbackJSON)

func (*XMLParser) RegisterMapCallback

func (x *XMLParser) RegisterMapCallback(match string, callback CallbackMap)

func (*XMLParser) SkipElements

func (x *XMLParser) SkipElements(skipElements []string) *XMLParser

func (*XMLParser) SkipOuterElements

func (x *XMLParser) SkipOuterElements() *XMLParser

by default skip elements works for stream elements childs if this method called parser skip also outer elements.

func (*XMLParser) Stream

func (x *XMLParser) Stream() error

Jump to

Keyboard shortcuts

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