Documentation
¶
Overview ¶
Package xmldoc reads XML documents into trees that keep them as written, and navigates them for XPath.
Index ¶
- func ElementXML(e *Node) string
- func TrimSpace(s string) string
- type Attr
- type Kind
- type Name
- type Nav
- func (x *Nav) Copy() xpath.NodeNavigator
- func (x *Nav) LocalName() string
- func (x *Nav) MoveTo(other xpath.NodeNavigator) bool
- func (x *Nav) MoveToChild() bool
- func (x *Nav) MoveToFirst() bool
- func (x *Nav) MoveToNext() bool
- func (x *Nav) MoveToNextAttribute() bool
- func (x *Nav) MoveToParent() bool
- func (x *Nav) MoveToPrevious() bool
- func (x *Nav) MoveToRoot()
- func (x *Nav) NamespaceURL() string
- func (x *Nav) Node() *Node
- func (x *Nav) NodeType() xpath.NodeType
- func (x *Nav) Prefix() string
- func (x *Nav) Value() string
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ElementXML ¶
ElementXML returns the XML of an element, with the namespace declarations its ancestors make that it doesn't make itself, the innermost of each prefix, so its names mean in it what they mean in the document.
Types ¶
type Attr ¶
type Attr struct {
Name Name
Value string
Decl bool // whether it declares a namespace, unless namespaces are ignored
}
Attr is an attribute of an element.
type Name ¶
Name is the name of an element or an attribute: its namespace URI, its prefix and its local name. When namespaces are ignored, Local is the name as written, with its prefix, and the others are empty.
type Nav ¶
type Nav struct {
// contains filtered or unexported fields
}
Nav navigates the tree of an XML document for XPath, as XPath 1.0 sees it: the document, its elements, their attributes, without namespace declarations, its text, white space included, and its comments. The xpath module has no node type for processing instructions, so it doesn't see them.
func (*Nav) MoveTo ¶
func (x *Nav) MoveTo(other xpath.NodeNavigator) bool
MoveTo implements xpath.NodeNavigator: to where other is.
func (*Nav) MoveToChild ¶
MoveToChild implements xpath.NodeNavigator.
func (*Nav) MoveToFirst ¶
MoveToFirst implements xpath.NodeNavigator: to the first sibling.
func (*Nav) MoveToNext ¶
MoveToNext implements xpath.NodeNavigator: to the next sibling.
func (*Nav) MoveToNextAttribute ¶
MoveToNextAttribute implements xpath.NodeNavigator.
func (*Nav) MoveToParent ¶
MoveToParent implements xpath.NodeNavigator: an attribute's parent is its element.
func (*Nav) MoveToPrevious ¶
MoveToPrevious implements xpath.NodeNavigator: to the previous sibling.
func (*Nav) NamespaceURL ¶
NamespaceURL returns the namespace URI of the name, which a prefix that XPathNamespace binds selects by.
func (*Nav) Node ¶
Node returns the node the navigator is on, or the element of the attribute it is on.
type Node ¶
type Node struct {
Kind Kind
Name Name // an element's; a processing instruction's target, as local
Attrs []Attr
Children []*Node
Parent *Node
Index int // the node's place among its parent's children
Text string // the data of text, a comment or a processing instruction
}
Node is a node of an XML document, as written: its text keeps its white space, its names their prefixes.