xml

package
v1.53.9 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package xml is XML testing package that supports XML comparison utility. The package consists of ToStruct and StructToXML utils that help sort XML elements as per their nesting level. ToStruct function converts an XML document into a sorted tree node structure, while StructToXML converts the sorted XML nodes into a sorted XML document. SortXML function should be used to sort an XML document. It can be configured to ignore indentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortXML

func SortXML(r io.Reader, ignoreIndentation bool) (string, error)

SortXML sorts the reader's XML elements

func StructToXML

func StructToXML(e *xml.Encoder, node *Node, sorted bool) error

StructToXML writes an Node to a xml.Encoder as tokens.

Types

type Node

type Node struct {
	Name     xml.Name           `json:",omitempty"`
	Children map[string][]*Node `json:",omitempty"`
	Text     string             `json:",omitempty"`
	Attr     []xml.Attr         `json:",omitempty"`
	// contains filtered or unexported fields
}

A Node contains the values to be encoded or decoded.

func NewXMLElement

func NewXMLElement(name xml.Name) *Node

NewXMLElement returns a pointer to a new Node initialized to default values.

func ToStruct

func ToStruct(d *xml.Decoder, s *xml.StartElement, ignoreIndentation bool) (*Node, error)

ToStruct converts a xml.Decoder stream to Node with nested values.

func (*Node) AddChild

func (n *Node) AddChild(child *Node)

AddChild adds child to the Node.

Jump to

Keyboard shortcuts

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