htmlelements

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: BSD-2-Clause Imports: 3 Imported by: 1

README

htmlelements

A simple package to replicate the common JavaScript getElementByID and getElementsByClassName functionality for GO. See the documenation at https://pkg.go.dev/github.com/jum/htmlelements

Documentation

Overview

Package htmlelements implements functions on parsed documents as returned by the golang.org/x/net/html package. These are patterned after the known JavaScript functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAttribute

func AddAttribute(n *html.Node, attrName, value string)

AddAttribute adds the named attribute, if the attribute is already present, the value will be appended with a blank as delimiter

func GetAttribute

func GetAttribute(n *html.Node, attrName string) string

GetAttribute searches the named attribute, returning the value or if not found an empty string.

func GetElementByID

func GetElementByID(doc *html.Node, id string) *html.Node

GetElementByID searches for the HTML element with the given id.

func GetElementsByClassName

func GetElementsByClassName(doc *html.Node, className string) []*html.Node

GetElementsByClassName searches the doc for all elements with the given class name.

func GetElementsByTagName

func GetElementsByTagName(doc *html.Node, tagName string) []*html.Node

GetElementsByTagName searches the doc for all elements with the given tag name.

func InnerText

func InnerText(n *html.Node) (ret string)

InnerText retrieves all the text of all the elements concatenated.

func RemoveAttribute

func RemoveAttribute(n *html.Node, attrName string)

RemoveAttribute removes the named attribute.

Types

This section is empty.

Jump to

Keyboard shortcuts

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