Documentation
¶
Index ¶
- func NewID() int
- type Appender
- type Attribute
- type CharData
- type Comment
- type Element
- func (elt *Element) Append(n XMLNode)
- func (elt *Element) Attributes() []*Attribute
- func (elt *Element) Children() []XMLNode
- func (elt *Element) GetID() int
- func (elt *Element) InnerXML() string
- func (elt *Element) SetAttribute(attr xml.Attr)
- func (elt Element) String() string
- func (elt *Element) Stringvalue() string
- func (elt *Element) ToXML() string
- type ProcInst
- type SortByDocumentOrder
- type XMLDocument
- type XMLNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Appender ¶
type Appender interface {
Append(n XMLNode)
}
Appender implements the function Append(XMLNode)
type Attribute ¶
type Attribute struct {
ID int
Name string
Namespace string
Prefix string
Value string
Parent XMLNode
}
Attribute represents an attribute
func (Attribute) Stringvalue ¶
Stringvalue returns the attribute value.
type Element ¶
type Element struct {
ID int
Name string
Prefix string
Parent XMLNode
Namespaces map[string]string
Line int
Pos int
// contains filtered or unexported fields
}
Element represents an XML element
func (*Element) Attributes ¶
Attributes returns all attributes for this element. Attribute objects are cached so they have stable IDs across calls.
func (*Element) InnerXML ¶ added in v1.0.5
InnerXML returns the XML representation of the children of this element.
func (*Element) SetAttribute ¶ added in v1.0.1
SetAttribute appends attr to the list of attributes of elt. If an attribute of this name already exists, the existing one will be discarded.
func (*Element) Stringvalue ¶
Stringvalue returns the text nodes of this elements and its children.
type SortByDocumentOrder ¶
type SortByDocumentOrder []XMLNode
SortByDocumentOrder sorts the nodes by document order.
func (SortByDocumentOrder) Len ¶
func (xn SortByDocumentOrder) Len() int
func (SortByDocumentOrder) Less ¶
func (xn SortByDocumentOrder) Less(i, j int) bool
func (SortByDocumentOrder) SortAndEliminateDuplicates ¶
func (xn SortByDocumentOrder) SortAndEliminateDuplicates() SortByDocumentOrder
SortAndEliminateDuplicates returns the nodes sorted in document order and duplicates deleted.
func (SortByDocumentOrder) Swap ¶
func (xn SortByDocumentOrder) Swap(i, j int)
type XMLDocument ¶
type XMLDocument struct {
ID int
// contains filtered or unexported fields
}
XMLDocument represents an XML file for decoding
func Parse ¶
func Parse(r io.Reader) (*XMLDocument, error)
Parse reads the XML file from r. r is not closed.
func (*XMLDocument) Append ¶
func (xr *XMLDocument) Append(n XMLNode)
Append appends an XML node to the document.
func (*XMLDocument) Children ¶
func (xr *XMLDocument) Children() []XMLNode
Children returns all child nodes from elt
func (XMLDocument) GetID ¶ added in v1.0.7
func (xr XMLDocument) GetID() int
GetID returns the ID of this node.
func (*XMLDocument) Root ¶
func (xr *XMLDocument) Root() (*Element, error)
Root returns the root node of the document
func (XMLDocument) String ¶
func (xr XMLDocument) String() string
func (*XMLDocument) Stringvalue ¶ added in v1.0.7
func (xr *XMLDocument) Stringvalue() string
Stringvalue returns the string value of the document node (concatenation of all descendant text nodes), analogous to Element.Stringvalue().
func (*XMLDocument) ToXML ¶
func (xr *XMLDocument) ToXML() string
ToXML returns a valid XML document