dom

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2022 Hal Canary Use of this program is governed by the file LICENSE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr

type Attr = map[string]string

type Node

type Node html.Node

Alias for golang.org/x/net/html.Node.

func Comment

func Comment(data string) *Node

Return a HTML comment with the given data.

func Elem

func Elem(tag string, children ...*Node) *Node

Return an element with the given children.

func Element

func Element(tag string, attributes Attr, children ...*Node) *Node

Return an element with given attributes and children.

func Parse

func Parse(source io.Reader) (*Node, error)

Wrapper for golang.org/x/net/html.Parse.

func RawHtml

func RawHtml(data string) *Node

func TextNode

func TextNode(data string) *Node

Return a HTML node with the given text.

func (*Node) AddAttribute

func (node *Node) AddAttribute(k, v string)

func (*Node) Append

func (node *Node) Append(children ...*Node) *Node

func (*Node) ExtractText

func (root *Node) ExtractText() string

Extract and combine all Text Nodes under given node.

func (*Node) FindAllMatchingNodes

func (node *Node) FindAllMatchingNodes(tag string) []*Node

func (*Node) FindOneMatchingNode

func (node *Node) FindOneMatchingNode(tag string) *Node

func (*Node) FindOneMatchingNode2

func (node *Node) FindOneMatchingNode2(tag, attributeKey, attributeValue string) *Node

func (*Node) GetAttribute

func (node *Node) GetAttribute(key string) string

Find the matching attributes, ignoring namespace.

func (*Node) GetFirstChild

func (node *Node) GetFirstChild() *Node

func (*Node) GetNextSibling

func (node *Node) GetNextSibling() *Node

func (*Node) GetParent

func (n *Node) GetParent() *Node

func (*Node) InsertBefore

func (n *Node) InsertBefore(v, o *Node)

func (*Node) Remove

func (node *Node) Remove() *Node

Remove a node from its parent.

func (*Node) RenderHTML

func (root *Node) RenderHTML(w io.Writer) error

Generates HTML5 doc.

func (*Node) RenderHTMLExperimental added in v0.3.0

func (root *Node) RenderHTMLExperimental(w io.Writer) error

Generates HTML5 doc.

func (*Node) RenderXHTMLDoc

func (root *Node) RenderXHTMLDoc(w io.Writer) error

Generates XHTML1 doc.

Jump to

Keyboard shortcuts

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