goxpath

package module
v0.0.0-...-97928f7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 7 Imported by: 87

README

Deprecated. Use xsel instead.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(n tree.Node, w io.Writer) error

Marshal prints the result tree, r, in XML form to w.

func MarshalStr

func MarshalStr(n tree.Node) (string, error)

MarshalStr is like Marhal, but returns a string.

func ParseExec

func ParseExec(xpstr string, t tree.Node, opts ...FuncOpts) (tree.Result, error)

ParseExec parses the XPath string, xpstr, and runs Exec.

Types

type FuncOpts

type FuncOpts func(*Opts)

FuncOpts is a function wrapper for Opts.

type Opts

type Opts struct {
	NS    map[string]string
	Funcs map[xml.Name]tree.Wrap
	Vars  map[string]tree.Result
}

Opts defines namespace mappings and custom functions for XPath expressions.

type XPathExec

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

XPathExec is the XPath executor, compiled from an XPath string

func MustParse

func MustParse(xp string) XPathExec

MustParse is like Parse, but panics instead of returning an error.

func Parse

func Parse(xp string) (XPathExec, error)

Parse parses the XPath expression, xp, returning an XPath executor.

func (XPathExec) Exec

func (xp XPathExec) Exec(t tree.Node, opts ...FuncOpts) (tree.Result, error)

Exec executes the XPath expression, xp, against the tree, t, with the namespace mappings, ns, and returns the result as a stringer.

func (XPathExec) ExecBool

func (xp XPathExec) ExecBool(t tree.Node, opts ...FuncOpts) (bool, error)

ExecBool is like Exec, except it will attempt to convert the result to its boolean value.

func (XPathExec) ExecNode

func (xp XPathExec) ExecNode(t tree.Node, opts ...FuncOpts) (tree.NodeSet, error)

ExecNode is like Exec, except it will attempt to return the result as a node-set.

func (XPathExec) ExecNum

func (xp XPathExec) ExecNum(t tree.Node, opts ...FuncOpts) (float64, error)

ExecNum is like Exec, except it will attempt to convert the result to its number value.

func (XPathExec) MustExec

func (xp XPathExec) MustExec(t tree.Node, opts ...FuncOpts) tree.Result

MustExec is like Exec, but panics instead of returning an error.

Jump to

Keyboard shortcuts

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