Documentation ¶
Index ¶
- func AppendChild(node *html.Node, child *html.Node)
- func ChildNodes(node *html.Node) []*html.Node
- func Children(node *html.Node) []*html.Node
- func ClassName(node *html.Node) string
- func CloneNode(src *html.Node) *html.Node
- func CreateElement(tagName string) *html.Node
- func CreateTextNode(data string) *html.Node
- func DocumentElement(doc *html.Node) *html.Node
- func FirstElementChild(node *html.Node) *html.Node
- func ForEachNode(nodeList []*html.Node, fn func(*html.Node, int))
- func GetAllNodesWithTag(node *html.Node, tagNames ...string) []*html.Node
- func GetAttribute(node *html.Node, attrName string) string
- func GetElementsByTagName(doc *html.Node, tagName string) []*html.Node
- func HasAttribute(node *html.Node, attrName string) bool
- func ID(node *html.Node) string
- func IncludeNode(nodeList []*html.Node, node *html.Node) bool
- func InnerHTML(node *html.Node) string
- func NextElementSibling(node *html.Node) *html.Node
- func OuterHTML(node *html.Node) string
- func PrependChild(node *html.Node, child *html.Node)
- func PreviousElementSibling(node *html.Node) *html.Node
- func RemoveAttribute(node *html.Node, attrName string)
- func RemoveNodes(nodeList []*html.Node, filterFn func(*html.Node) bool)
- func ReplaceChild(parent *html.Node, newChild *html.Node, oldChild *html.Node) (*html.Node, *html.Node)
- func SetAttribute(node *html.Node, attrName string, attrValue string)
- func SetTextContent(node *html.Node, text string)
- func TagName(node *html.Node) string
- func TextContent(node *html.Node) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendChild ¶
AppendChild adds a node to the end of the list of children of a specified parent node. If the given child is a reference to an existing node in the document, AppendChild() moves it from its current position to the new position.
func ChildNodes ¶
ChildNodes returns list of a node's direct children.
func CloneNode ¶
CloneNode returns a deep clone of the node and its children. However, it will be detached from the original's parents and siblings.
func CreateElement ¶
CreateElement creates a new ElementNode with specified tag.
func CreateTextNode ¶
CreateTextNode creates a new Text node.
func DocumentElement ¶
DocumentElement returns the Element that is the root element of the document. Since we are working with HTML document, the root will be <html> element for HTML documents).
func FirstElementChild ¶
FirstElementChild returns the object's first child Element, or nil if there are no child elements.
func ForEachNode ¶
ForEachNode iterates over a NodeList and runs fn on each node.
func GetAllNodesWithTag ¶
GetAllNodesWithTag is wrapper for GetElementsByTagName() which allow to get several tags at once.
func GetAttribute ¶
GetAttribute returns the value of a specified attribute on the element. If the given attribute does not exist, the value returned will be an empty string.
func GetElementsByTagName ¶
GetElementsByTagName returns a collection of all elements in the document with the specified tag name, as an array of Node object. The special tag "*" will represents all elements.
func HasAttribute ¶
HasAttribute returns a Boolean value indicating whether the specified node has the specified attribute or not.
func IncludeNode ¶
IncludeNode determines if node is included inside nodeList.
func InnerHTML ¶
InnerHTML returns the HTML content (inner HTML) of an element. The returned HTML value is escaped.
func NextElementSibling ¶
NextElementSibling returns the Element immediately following the specified one in its parent's children list, or nil if the specified Element is the last one in the list.
func OuterHTML ¶
OuterHTML returns an HTML serialization of the element and its descendants. The returned HTML value is escaped.
func PrependChild ¶
PrependChild works like AppendChild() except it adds a node to the beginning of the list of children of a specified parent node.
func PreviousElementSibling ¶
PreviousElementSibling returns the the Element immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list.
func RemoveAttribute ¶
RemoveAttribute removes attribute with given name.
func RemoveNodes ¶
RemoveNodes iterates over a NodeList, calls `filterFn` for each node and removes node if function returned `true`. If function is not passed, removes all the nodes in node list.
func ReplaceChild ¶
func ReplaceChild(parent *html.Node, newChild *html.Node, oldChild *html.Node) (*html.Node, *html.Node)
ReplaceChild replaces a child node within the given (parent) node. If the new child is already exist in document, ReplaceChild() will move it from its current position to replace old child. Returns both the new and old child.
func SetAttribute ¶
SetAttribute sets attribute for node. If attribute already exists, it will be replaced.
func SetTextContent ¶
SetTextContent sets the text content of the specified node.
func TagName ¶
TagName returns the tag name of a Node. If it's not ElementNode, return empty string.
func TextContent ¶
TextContent returns the text content of the specified node, and all its descendants.
Types ¶
This section is empty.