runxml

package module
v0.0.0-...-2f0df33 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: MIT Imports: 5 Imported by: 0

README

The RunXML library

RunXML library is a Go XML library, with focus on speed.
It is mostly based on the RapidXML by Marcin Kalicinski.

WARNING: Work in progress

This library is WIP, do not use it for anything at this moment.

Documentation

https://godoc.org/github.com/robfordww/runxml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeNode

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

AttributeNode represents the attribute (a="abc") of a node

func (*AttributeNode) String

func (a *AttributeNode) String() string

String representation of a attribute node

type GenericNode

type GenericNode struct {
	NodeType NodeType // NodeType enum (doc, element etc.)
	// contains filtered or unexported fields
}

GenericNode is the datastruct for all "node types" as defined above

func (*GenericNode) AppendAttribute

func (g *GenericNode) AppendAttribute(a *AttributeNode)

AppendAttribute appends an attribute to a node

func (*GenericNode) AppendNode

func (g *GenericNode) AppendNode(child *GenericNode)

AppendNode appends a new child node to a node

func (*GenericNode) CountChildren

func (g *GenericNode) CountChildren() int

CountChildren returns the nodes number of childre. The node itself is not included.

func (*GenericNode) GetAttributes

func (g *GenericNode) GetAttributes() []*AttributeNode

GetAttributes returns a slice of pointers to the attributes of the node

func (*GenericNode) GetFirstChild

func (g *GenericNode) GetFirstChild() *GenericNode

GetFirstChild returns the first child of the node, if no child exists, it returns null

func (*GenericNode) GetLastChild

func (g *GenericNode) GetLastChild() *GenericNode

GetLastChild returns the last child of the node, if no child exists, it returns null

func (*GenericNode) GetNextSibling

func (g *GenericNode) GetNextSibling() *GenericNode

GetNextSibling returns the next sibling of the node, if no siblings exist, or we reached the end of the siblings it returns null

func (*GenericNode) GetPreviousSibling

func (g *GenericNode) GetPreviousSibling() *GenericNode

GetPreviousSibling returns the previous sibling of the node, if no siblings exist, or we reached the first of the siblings it returns null

func (*GenericNode) InsertAttribute

func (g *GenericNode) InsertAttribute(where, a *AttributeNode)

InsertAttribute inserts an attribute before the specified child node

func (*GenericNode) InsertNode

func (g *GenericNode) InsertNode(where, child *GenericNode)

InsertNode inserts a child before the specified child node

func (*GenericNode) PrependAttribute

func (g *GenericNode) PrependAttribute(a *AttributeNode)

PrependAttribute prepends an attribute to the current node

func (*GenericNode) PrependNode

func (g *GenericNode) PrependNode(child *GenericNode)

PrependNode inserts a child as the first node

func (*GenericNode) PrintChildren

func (g *GenericNode) PrintChildren()

PrintChildren prints a representation of the node, including its children

func (*GenericNode) PrintXML

func (g *GenericNode) PrintXML()

PrintXML writes to stdout an XML representation of the node structure.

func (*GenericNode) PrintXMLPretty

func (g *GenericNode) PrintXMLPretty()

PrintXMLPretty writes to stdout an XML representation of the node structure and inserting indenting and line breaking characters for prettier formatting

func (*GenericNode) RemoveAllNodes

func (g *GenericNode) RemoveAllNodes()

RemoveAllNodes removes all child nodes, but not attributes of the current node

func (*GenericNode) RemoveAttribute

func (g *GenericNode) RemoveAttribute(where *AttributeNode)

RemoveAttribute deletes the specified attribute

func (*GenericNode) RemoveFirstAttribute

func (g *GenericNode) RemoveFirstAttribute()

RemoveFirstAttribute deletes the first attribute

func (*GenericNode) RemoveFirstNode

func (g *GenericNode) RemoveFirstNode()

RemoveFirstNode deletes the first child of the node

func (*GenericNode) RemoveLastAttribute

func (g *GenericNode) RemoveLastAttribute()

RemoveLastAttribute delets the last attribute

func (*GenericNode) RemoveLastNode

func (g *GenericNode) RemoveLastNode()

RemoveLastNode deletes the last child of the node

func (*GenericNode) RemoveNode

func (g *GenericNode) RemoveNode(where *GenericNode)

RemoveNode deletes a particular child node of the current node

func (*GenericNode) SendChildElements

func (g *GenericNode) SendChildElements() (ret chan *GenericNode)

SendChildElements returns a channel of pointers to all child elements of the node

func (*GenericNode) SendCloseChildren

func (g *GenericNode) SendCloseChildren() (ret chan *GenericNode)

SendCloseChildren returns a channel of pointers to all direct children, but not their children. This is useful for breadth first parsing

func (*GenericNode) String

func (g *GenericNode) String() string

String representation of a GenericNode

type NodeType

type NodeType int

NodeType is the datatype descriping all possible node types

const (
	Document    NodeType = iota //!< A document node. Name and value are empty.
	Element                     //!< An element node. Name contains element name. Value contains text of first data node.
	Data                        //!< A data node. Name is empty. Value contains data text.
	Cdata                       //!< A CDATA node. Name is empty. Value contains data text.
	Comment                     //!< A comment node. Name is empty. Value contains comment text.
	Declaration                 //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes.
	Doctype                     //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text.
	Pi                          //!< A PI node. Name contains target. Value contains instructions.
)

NodeType enum values

func (NodeType) String

func (i NodeType) String() string

type RunXML

type RunXML struct {
	ValidateClosingTag bool
	// contains filtered or unexported fields
}

RunXML is the parser instance that tracks the holds all state info

func NewDefaultRunXML

func NewDefaultRunXML() *RunXML

NewDefaultRunXML creates a standard parser setup.

func (*RunXML) Parse

func (r *RunXML) Parse(b []byte) (*GenericNode, error)

Parse parses the entire byte slice. Returns a pointer to GenericNode, representing the entire XML DOM-tree

func (*RunXML) ParseFile

func (r *RunXML) ParseFile(fn string) (*GenericNode, error)

ParseFile is a wrapper for Parse to simplify loading of files

Directories

Path Synopsis
The rxgen is the command line utility that generates the Unmarshal and Marshal methods of selected structs.
The rxgen is the command line utility that generates the Unmarshal and Marshal methods of selected structs.

Jump to

Keyboard shortcuts

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