etree

package
v0.0.0-...-f6732a9 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(node, subelement *html.Node)

Append appends single subelement into the node.

func Element

func Element(tagName string) *html.Node

Element returns a html.Node with specified tag name.

func Extend

func Extend(node *html.Node, subelements ...*html.Node)

Extend appends subelements into the node.

func FromString

func FromString(str string) *html.Node

FromString parses an HTML document or element from a string.

func Iter

func Iter(element *html.Node, tags ...string) []*html.Node

Iter loops over this element and all subelements in document order, and returns all elements with a matching tag.

func IterText

func IterText(node *html.Node, separator string) string

IterText loops over this element and all subelements in document order, and returns all inner text. Similar with dom.TextContent, except here we add whitespaces when element level changed.

func Remove

func Remove(element *html.Node, keepTail ...bool)

Remove will removes the element and its entire subtree, including all of its attributes, text content and descendants. It will also remove the tail text of the element unless you explicitly set the keepTail argument to true.

func SetTail

func SetTail(element *html.Node, tail string)

SetTail sets the value for element's tail.

func SetText

func SetText(element *html.Node, text string)

SetText sets the value for element's text.

func Strip

func Strip(element *html.Node)

Strip will removes the element but not their text/tail content or descendants. Instead, it will merge the text content and children of the element into its parent.

func StripElements

func StripElements(tree *html.Node, keepTail bool, tags ...string)

StripElements deletes all elements with the provided tag names from a tree or subtree. This will remove the elements and their entire subtree, including all their attributes, text content and descendants. It will also remove the tail text of the element unless you explicitly set the keepTail argument to true.

func StripTags

func StripTags(tree *html.Node, tags ...string)

StripTags deletes all elements with the provided tag names from a tree or subtree. This will remove the elements and their attributes, but not their text/tail content or descendants. Instead, it will merge the text content and children of the element into its parent.

func SubElement

func SubElement(parent *html.Node, tagName string) *html.Node

SubElement creates a html.Node with specified tag name, and append it to an existing element.

func Tail

func Tail(element *html.Node) string

Tail returns text after this element's end tag, but before the next sibling element's start tag. If there was no text, this function will returns an empty string.

func TailNodes

func TailNodes(element *html.Node) []*html.Node

TailNodes returns the list of tail nodes for the element.

func Text

func Text(element *html.Node) string

Text returns texts before first subelement. If there was no text, this function will returns an empty string.

func ToString

func ToString(tree *html.Node, prettify ...bool) string

ToString encode an element to string representation of its structure.

Types

This section is empty.

Jump to

Keyboard shortcuts

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