Documentation ¶
Overview ¶
Collection of functions that help navigating through an html5 DOM tree.
Index ¶
- func AttrVal(n *html.Node, namespace, key string) string
- func ElementByID(n *html.Node, id string) *html.Node
- func ElementsByAttr(n *html.Node, attr ...html.Attribute) []*html.Node
- func ElementsByAttrMatch(n *html.Node, namespace, key string, val *regexp.Regexp) []*html.Node
- func ElementsByClassName(n *html.Node, name ...string) []*html.Node
- func ElementsByTag(n *html.Node, tag ...atom.Atom) []*html.Node
- func ElementsByTagAndAttr(n *html.Node, tag atom.Atom, attr ...html.Attribute) []*html.Node
- func FirstElementByAttr(n *html.Node, attr ...html.Attribute) *html.Node
- func FirstElementByClassName(n *html.Node, name ...string) *html.Node
- func FirstElementByTag(n *html.Node, tag ...atom.Atom) *html.Node
- func FirstElementByTagAndAttr(n *html.Node, tag atom.Atom, attr ...html.Attribute) *html.Node
- func FirstNodeByType(n *html.Node, t html.NodeType) *html.Node
- func HasAttr(n *html.Node, namespace, key string) bool
- func MatchAttrs(n *html.Node, attr ...html.Attribute) bool
- func NextElementSibling(n *html.Node) *html.Node
- func NextSiblingByTag(n *html.Node, tag ...atom.Atom) *html.Node
- func PrevElementSibling(n *html.Node) *html.Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttrVal ¶
Returns the corresponding attribute value if node n has an attribute of the given namespace and key. If no such attribute exists, an empty string will be returned.
func ElementByID ¶
Executes depth-first search on all child nodes of n, returns the first element found with the given id. If no suitable element was found, nil will be returned.
func ElementsByAttr ¶ added in v0.2.0
Executes depth-first search on all child nodes of n and returns all elements that contain all given attributes. Returns nil if no matches were found.
func ElementsByAttrMatch ¶
Executes depth-first search on all child nodes of n, returns a slice that contains all elements that have an attribute where namespace and key are equal to the function args and where the attribute's val matches the given regular expression. If no proper element was found, nil will be returned.
func ElementsByClassName ¶ added in v0.2.0
Executes depth-first search on all child nodes of n and returns all elements that are a member of all given classes. Returns nil if no such elements were found.
func ElementsByTag ¶
Executes depth-first search on all child nodes of n and returns all elements that match at least one of the given tags. Returns nil if no such element was found.
func ElementsByTagAndAttr ¶
Executes depth-first search on all child nodes of n and returns all elements that match the given tag and contain all given attributes. Returns nil if no matches were found.
func FirstElementByAttr ¶ added in v0.2.0
Executes depth-first search on all child nodes of n and returns the first element that contains all given attributes. Returns nil if no match was found.
func FirstElementByClassName ¶ added in v0.2.0
Executes depth-first search on all child nodes of n and returns the first element that is a member of all given classes. Returns nil if no such element was found.
func FirstElementByTag ¶
Executes depth-first search on all child nodes of n and returns the first element that matches at least one of the given tags. Returns nil if no such element was found.
func FirstElementByTagAndAttr ¶ added in v0.2.0
Executes depth-first search on all child nodes of n and returns the first element that matches the given tag and contains all given attributes. Returns nil if no match was found.
func FirstNodeByType ¶ added in v0.2.0
Executes depth-first search on all child nodes of n, returns the first node that matches NodeType t or nil if no such node was found.
func HasAttr ¶
Returns true if node n has an attribute that matches namespace and key, returns false otherwise.
func MatchAttrs ¶
Returns true if node n contains all given attributes, returns false otherwise.
func NextElementSibling ¶ added in v0.2.0
Returns the node's next sibling that is an element. Returns nil if no such element was found.
func NextSiblingByTag ¶ added in v0.2.0
Returns the node's next sibling where at least one of the given tags match. Returns nil if no such node was found.
Types ¶
This section is empty.