rottensoup

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: BSD-2-Clause Imports: 5 Imported by: 0

README

ABOUT

Go library for html5 DOM manipulation.

DOCUMENTATION

Documentation is available through go doc.

LEGAL

This software uses Go, Go is distributed under the following license:

Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

   * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
   * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation

Overview

Collection of functions that help navigating through an html5 DOM tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttrVal

func AttrVal(n *html.Node, namespace, key string) string

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

func ElementByID(n *html.Node, id string) *html.Node

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

func ElementsByAttr(n *html.Node, attr ...html.Attribute) []*html.Node

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

func ElementsByAttrMatch(n *html.Node, namespace, key string, val *regexp.Regexp) []*html.Node

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

func ElementsByClassName(n *html.Node, name ...string) []*html.Node

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

func ElementsByTag(n *html.Node, tag ...atom.Atom) []*html.Node

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

func ElementsByTagAndAttr(n *html.Node, tag atom.Atom, attr ...html.Attribute) []*html.Node

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

func FirstElementByAttr(n *html.Node, attr ...html.Attribute) *html.Node

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

func FirstElementByClassName(n *html.Node, name ...string) *html.Node

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

func FirstElementByTag(n *html.Node, tag ...atom.Atom) *html.Node

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

func FirstElementByTagAndAttr(n *html.Node, tag atom.Atom, attr ...html.Attribute) *html.Node

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

func FirstNodeByType(n *html.Node, t html.NodeType) *html.Node

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

func HasAttr(n *html.Node, namespace, key string) bool

Returns true if node n has an attribute that matches namespace and key, returns false otherwise.

func MatchAttrs

func MatchAttrs(n *html.Node, attr ...html.Attribute) bool

Returns true if node n contains all given attributes, returns false otherwise.

func NextElementSibling added in v0.2.0

func NextElementSibling(n *html.Node) *html.Node

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

func NextSiblingByTag(n *html.Node, tag ...atom.Atom) *html.Node

Returns the node's next sibling where at least one of the given tags match. Returns nil if no such node was found.

func PrevElementSibling added in v0.2.0

func PrevElementSibling(n *html.Node) *html.Node

Returns the node's next previous sibling that is an element. Returns nil if no such element was found.

Types

This section is empty.

Directories

Path Synopsis
internal
nav

Jump to

Keyboard shortcuts

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