htmlnode

package
v0.0.0-...-c9993b8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package htmlnode contains helpers to interact with html.Node

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendAttribute

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

AppendAttribute appends to any existing value of the attribute on node n with namespace and key with val. If the attribute doesn't exist, it adds it.

func AppendAttributeWithSeparator

func AppendAttributeWithSeparator(n *html.Node, namespace, key, val, sep string)

AppendAttributeWithSeparator appends to any existing value of the attribute on node n with namespace and key with val. If the attribute doesn't exist, it adds it. If the attribute already exists, uses the given separator before appending the new value.

func AppendChildren

func AppendChildren(p *html.Node, c ...*html.Node)

AppendChildren appends the array of nodes to node n.

func Element

func Element(tag string, attrs ...html.Attribute) *html.Node

Element returns an html.Node for an element with tag and attributes

func FindAttribute

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

FindAttribute returns a pointer to the attribute of node n with the given namespace and key or ok=false if there is none.

func FindNode

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

FindNode returns the (first) specified child node of the given atom type or ok=false if there are none.

func GetAttributeVal

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

GetAttributeVal returns the value for the attribute named with 'key' or ok=false if the attribute doesn't exist.

func GetAttributeValOrNil

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

GetAttributeValOrNil returns a pointer to the value for the attribute named with 'key' or nil if the attribute doesn't exist. There are cases when it is necessary to differentiate between nil versus empty (which is imposible from Go primitives).

func HasAttribute

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

HasAttribute returns true if the node has the attribute named with 'key'.

func IsChildOf

func IsChildOf(n *html.Node, atom atom.Atom) bool

IsChildOf returns true if the node is a direct descendant (immediate child) of the given atom.

func IsDescendantOf

func IsDescendantOf(n *html.Node, atom atom.Atom) bool

IsDescendantOf returns true if the node is a descendant of the given atom, regardless of distance (e.g. the node can be child, or grandchild, or great grandchild, etc.).

func Next

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

Next returns the next node in depth first order.

func PrependAttribute

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

PrependAttribute prepends to any existing value of the attribute on node n with namespace and key with val. If the attribute doesn't exist, it adds it.

func Prev

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

Prev returns the prev node in depth first order.

func RemoveAllChildren

func RemoveAllChildren(n *html.Node)

RemoveAllChildren removes all children from node n.

func RemoveAttribute

func RemoveAttribute(n *html.Node, a *html.Attribute)

RemoveAttribute removes the given attribute from node n. If it doesn't exist, this does nothing.

func RemoveNode

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

RemoveNode removes the node and adjusts the Node pointer to continue iterating over the remaining tree nodes. Returns the removed node.

func SetAttribute

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

SetAttribute overrides the value of the attribute on node n with namespace and key with val. If the attribute doesn't exist, it adds it.

func Text

func Text(t string) *html.Node

Text returns an html.Node containing the given string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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