xml

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 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 XMLToStruct and StructToXML utils that help sort xml elements as per their nesting level. XMLToStruct 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 *XMLNode, sorted bool) error

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

Types

type XMLNode

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

A XMLNode contains the values to be encoded or decoded.

func NewXMLElement

func NewXMLElement(name xml.Name) *XMLNode

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

func XMLToStruct

func XMLToStruct(d *xml.Decoder, s *xml.StartElement, ignoreIndentation bool) (*XMLNode, error)

XMLToStruct converts a xml.Decoder stream to XMLNode with nested values.

func (*XMLNode) AddChild

func (n *XMLNode) AddChild(child *XMLNode)

AddChild adds child to the XMLNode.

Jump to

Keyboard shortcuts

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