Documentation
¶
Index ¶
- func Prepare(n *Node) error
- func TextString(n *Node) (string, error)
- func XMLString(n *Node) (string, error)
- type Node
- func NewAttribute(name []byte, value []byte) *Node
- func NewCData(value []byte) *Node
- func NewComment(value []byte) *Node
- func NewData(value []byte) *Node
- func NewDeclaration() *Node
- func NewDirectory(name []byte) *Node
- func NewDoctype(value []byte) *Node
- func NewDocument(name []byte) *Node
- func NewElement(name []byte) *Node
- func NewNode(t NodeType) *Node
- func NewNotXML(name []byte, value []byte) *Node
- func NewProcInstr(name []byte, value []byte) *Node
- type NodeType
- type Stack
- type TextEncoder
- type XMLEncoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TextString ¶
TextString is a helper function to quickly get string representation of the node tree in text format.
Types ¶
type Node ¶
type Node struct { Type NodeType Parent *Node FirstChild *Node NextSibling *Node PrevSiblingCyclic *Node Name []byte Value []byte Hash []byte Signature []byte }
Node represents node of the xtree.
func NewAttribute ¶
NewAttribute creates new node with Attribute type.
func NewComment ¶
NewComment creates new node with Comment type.
func NewDeclaration ¶
func NewDeclaration() *Node
NewDeclaration creates new node with Declaration type.
func NewDirectory ¶
NewDirectory creates new node with Directory type.
func NewDoctype ¶
NewDoctype creates new node with Doctype type.
func NewDocument ¶
NewDocument creates new node with Document type.
func NewProcInstr ¶
NewProcInstr creates new node with ProcInstr type.
func (*Node) AppendChild ¶
AppendChild appends child node to the node.
func (*Node) CalculateHash ¶
CalculateHash sets hash value of the node.
func (*Node) CalculateSignature ¶
func (n *Node) CalculateSignature()
CalculateSignature sets signature value of the node.
func (*Node) PrevSibling ¶
PrevSibling returns previous sibling of the node.
type NodeType ¶
type NodeType int
NodeType is describing possible node types.
const ( // Node is not xml file. NotXML NodeType = iota // A directory node. Name is same as directory name. Value is empty. Directory // A document node. If result of directory parsing name is same as the filename otherwise it's empty. Value is empty. Document // An element node. Name contains element name. Value contains text of first data node. Element // An attribute node. Name contains attribute name. Value contains attribute value. Attribute // A data node. Name is empty. Value contains text data. Data // A CDATA node. Name is empty. Value contains text data. CData // A comment node. Name is empty. Value contains comment text. Comment // A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes. Declaration // A DOCTYPE node. Name is empty. Value contains DOCTYPE text. Doctype // A ProcInstr node. Name contains target. Value contains instructions. ProcInstr )
NodeType values.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is auxiliary data structure for iterative xtree traversal.
type TextEncoder ¶
type TextEncoder struct {
// contains filtered or unexported fields
}
TextEncoder knows how to encode node tree as text format suitable for command line output.
func NewTextEncoder ¶
func NewTextEncoder(w io.Writer) *TextEncoder
NewTextEncoder creates new textual encoder that writes text into the writer.
func (*TextEncoder) Encode ¶
func (enc *TextEncoder) Encode(n *Node) error
Encode writes node tree rooted at n to the stream.
type XMLEncoder ¶
type XMLEncoder struct {
// contains filtered or unexported fields
}
XMLEncoder knows how to encode node tree to XML format.
func NewXMLEncoder ¶
func NewXMLEncoder(w io.Writer) *XMLEncoder
NewXMLEncoder creates new XMLEncoder that writes xml into the writer.
func (*XMLEncoder) Encode ¶
func (enc *XMLEncoder) Encode(n *Node) error
Encode writes node tree rooted at n to the stream.
func (*XMLEncoder) Indent ¶
func (enc *XMLEncoder) Indent(indent string)
Indent sets the encoder to generate XML in which each element begins on a new indented line that starts with one or more copies of indent according to the nesting depth.