htmlutil

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAttribute

func AddAttribute(node *html.Node, key string, val string)

AddAttribute adds an attribute to the node

func AppendAttribute

func AppendAttribute(node *html.Node, key string, val string)

AppendAttribute appends the new value to any existing attribute with the same name, separating them with a space

func Attr

func Attr(key string, val string) html.Attribute

Attr creates a new Attribute

func CreateNode

func CreateNode(data string, dataAtom atom.Atom, values ...interface{}) *html.Node

CreateNode creates an html Node and sets attributes or adds child nodes according to the type of each value

func FindAllNodes

func FindAllNodes(n *html.Node, all ...atom.Atom) []*html.Node

FindAllNodes returns all child nodes of any of the given types, in the order in which they are found (a depth-first search)

func FindNode

func FindNode(n *html.Node, a atom.Atom) *html.Node

FindNode is a depth-first search for the first node of the given type

func FindNodeWithAttributes

func FindNodeWithAttributes(n *html.Node, a atom.Atom, attr map[string]string) *html.Node

FindNodeWithAttributes is a depth-first search for the first node of the given type with the given attributes

func FindNodes

func FindNodes(n *html.Node, a atom.Atom) []*html.Node

FindNodes returns all child nodes of the given type

func FindNodesWithAttributes

func FindNodesWithAttributes(n *html.Node, a atom.Atom, attr map[string]string) []*html.Node

FindNodesWithAttributes returns all child nodes of the given type with the given attributes

func GetAttribute

func GetAttribute(node *html.Node, key string) string

GetAttribute finds an attribute for the node - returns empty string if not found

func GetText

func GetText(n *html.Node) string

GetText returns the text content of the given node, including the text content of all child nodes. Extraneous newline characters are removed.

func HasAttributes

func HasAttributes(n *html.Node, attr map[string]string) bool

HasAttributes returns true if the given node has all the attribute values

func ReplaceAttribute

func ReplaceAttribute(node *html.Node, key string, val string)

ReplaceAttribute adds an attribute to the node, replacing any existing attribute with the same name

func Text

func Text(text string) *html.Node

Text creates a new Text node

Types

This section is empty.

Jump to

Keyboard shortcuts

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