search

package
v0.0.0-...-0bff936 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2018 License: Apache-2.0 Imports: 3 Imported by: 16

Documentation

Overview

Package search contains searching routines for the simplexml/dom package. For some basic usage exmaples, see search_test.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(fn Match, nodes []*dom.Element) []*dom.Element

All returns all the nodes that fn matches

func First

func First(fn Match, nodes []*dom.Element) *dom.Element

First returns the first element that fn matches

func FirstTag

func FirstTag(name, space string, nodes []*dom.Element) *dom.Element

FirstTag finds the first element in the set of nodes that matches the tag name and namespace.

func MustFirstTag

func MustFirstTag(name, space string, nodes []*dom.Element) *dom.Element

MustFirstTag is the same as FirstTag, but it panics if the tag cannot be found

Types

type Match

type Match func(*dom.Element) bool

Match is the basic type of a search function. It takes a single element, and returns a boolean indicating whether the element matched the func.

func Always

func Always() Match

Always returns a matcher that always matches

func Ancestor

func Ancestor(fn Match) Match

Ancestor returns a matcher that matches iff the element has an ancestor that matches the passed matcher

func AncestorN

func AncestorN(fn Match, distance uint) Match

AncestorN returns a matcher that matches against the nth ancestor of the node being tested. If n == 0, then the node itself will be tested as a degenerate case. If there is no such ancestor the match fails.

func And

func And(funcs ...Match) Match

And takes any number of Match, and returns another Match that will match if all of passed Match functions match.

func Attr

func Attr(name, space, value string) Match

Attr creates a Match against the attributes of an element. It follows the same rules as Tag

func AttrRE

func AttrRE(name, space, value *regexp.Regexp) Match

AttrRE creates a Match against the attributes of an element. It follows the same rules as MatchRE

func Child

func Child(fn Match) Match

Child returns a matcher that matches iff the element has a child that matches the passed fn.

func Content

func Content(content []byte) Match

Content creates a Match against an element that tests to see if it matches the supplied content.

func ContentExists

func ContentExists() Match

ContentExists creates a Match against an element that has non-empty Content.

func ContentRE

func ContentRE(regex *regexp.Regexp) Match

ContentRE creates a Match against the Content of am element that passes if the regex matches the content.

func Never

func Never() Match

Never returns a matcher that never matches

func NoParent

func NoParent() Match

NoParent returns a matcher that matches iff the element does not have a parent

func Not

func Not(fn Match) Match

Not takes a single Match, and returns another Match that matches if fn does not match.

func Or

func Or(funcs ...Match) Match

Or takes any number of Match, and returns another Match that will match if any of the passed Match functions match.

func Parent

func Parent(fn Match) Match

Parent returns a matcher that matches iff the element has a parent and that parent matches the passed fn.

func Tag

func Tag(name, space string) Match

Tag is a helper function for matching against a specific tag. It takes a name and a namespace URL to match against. If either name or space are "*", then they will match any value. Return is a Match.

func TagRE

func TagRE(name, space *regexp.Regexp) Match

TagRE is a helper function for matching against a specific tag using regular expressions. It follows roughly the same rules as search.Tag Return is a Match

Jump to

Keyboard shortcuts

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