xmlpath

package module
v0.0.0-...-13f4951 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2014 License: LGPL-3.0 Imports: 5 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iter

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

Iter iterates over node sets.

func (*Iter) Next

func (iter *Iter) Next() bool

Next iterates to the next node in the set, if any, and returns whether there is a node available.

func (*Iter) Node

func (iter *Iter) Node() *Node

Node returns the current node. Must only be called after Iter.Next returns true.

type Namespace

type Namespace struct {
	Prefix string
	Uri    string
}

Namespace represents a given XML Namespace

type Node

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

Node is an item in an xml tree that was compiled to be processed via xml paths. A node may represent:

  • An element in the xml document (<body>)
  • An attribute of an element in the xml document (href="...")
  • A comment in the xml document (<!--...-->)
  • A processing instruction in the xml document (<?...?>)
  • Some text within the xml document

func Parse

func Parse(r io.Reader) (*Node, error)

Parse reads an xml document from r, parses it, and returns its root node.

func ParseDecoder

func ParseDecoder(d *xml.Decoder) (*Node, error)

ParseDecoder parses the xml document being decoded by d and returns its root node.

func ParseHTML

func ParseHTML(r io.Reader) (*Node, error)

ParseHTML reads an HTML-like document from r, parses it, and returns its root node.

func (*Node) Bytes

func (node *Node) Bytes() []byte

Bytes returns the string value of node as a byte slice. See Node.String for a description of what the string value of a node is.

func (*Node) String

func (node *Node) String() string

String returns the string value of node.

The string value of a node is:

  • For element nodes, the concatenation of all text nodes within the element.
  • For text nodes, the text itself.
  • For attribute nodes, the attribute value.
  • For comment nodes, the text within the comment delimiters.
  • For processing instruction nodes, the content of the instruction.

type Path

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

Path is a compiled path that can be applied to a context node to obtain a matching node set. A single Path can be applied concurrently to any number of context nodes.

func Compile

func Compile(path string) (*Path, error)

Compile returns the compiled path.

func CompileWithNamespace

func CompileWithNamespace(path string, ns []Namespace) (*Path, error)

Compile the path with the knowledge of the given namespaces

func MustCompile

func MustCompile(path string) *Path

MustCompile returns the compiled path, and panics if there are any errors.

func (*Path) Bytes

func (p *Path) Bytes(node *Node) (b []byte, ok bool)

Bytes returns as a byte slice the string value of the first node matched by p on the given context.

See the documentation of Node.String.

func (*Path) Exists

func (p *Path) Exists(context *Node) bool

Exists returns whether any nodes match p on the given context.

func (*Path) Iter

func (p *Path) Iter(context *Node) *Iter

Iter returns an iterator that goes over the list of nodes that p matches on the given context.

func (*Path) String

func (p *Path) String(context *Node) (s string, ok bool)

String returns the string value of the first node matched by p on the given context.

See the documentation of Node.String.

Jump to

Keyboard shortcuts

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