Documentation ¶
Overview ¶
Package htmlnode contains helpers to interact with html.Node
Index ¶
- func AppendAttribute(n *html.Node, namespace, key, val string)
- func AppendAttributeWithSeparator(n *html.Node, namespace, key, val, sep string)
- func AppendChildren(p *html.Node, c ...*html.Node)
- func Element(tag string, attrs ...html.Attribute) *html.Node
- func FindAttribute(n *html.Node, namespace, key string) (*html.Attribute, bool)
- func FindNode(n *html.Node, atom atom.Atom) (*html.Node, bool)
- func GetAttributeVal(n *html.Node, namespace, key string) (string, bool)
- func GetAttributeValOrNil(n *html.Node, namespace, key string) *string
- func HasAttribute(n *html.Node, namespace, key string) bool
- func HasAttributeAndIsNotEmpty(n *html.Node, namespace, key string) bool
- func IsChildOf(n *html.Node, atom atom.Atom) bool
- func IsDescendantOf(n *html.Node, atom atom.Atom) bool
- func Next(n *html.Node) *html.Node
- func NextSkippingChildren(n *html.Node) *html.Node
- func PrependAttribute(n *html.Node, namespace, key, val string)
- func Prev(n *html.Node) *html.Node
- func RemoveAllChildren(n *html.Node)
- func RemoveAttribute(n *html.Node, a *html.Attribute)
- func RemoveNode(n **html.Node) *html.Node
- func SetAttribute(n *html.Node, namespace, key, val string)
- func Text(t string) *html.Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendAttribute ¶
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 ¶
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 ¶
AppendChildren appends the array of nodes to node n.
func FindAttribute ¶
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 ¶
FindNode returns the (first) specified child node of the given atom type or ok=false if there are none.
func GetAttributeVal ¶
GetAttributeVal returns the value for the attribute named with 'key' or ok=false if the attribute doesn't exist.
func GetAttributeValOrNil ¶
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 ¶
HasAttribute returns true if the node has the attribute named with 'key'.
func HasAttributeAndIsNotEmpty ¶
HasAttributeAndIsNotEmpty return true if the node has the attribute named with 'key' and it's value is not empty.
func IsChildOf ¶
IsChildOf returns true if the node is a direct descendant (immediate child) of the given atom.
func IsDescendantOf ¶
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 NextSkippingChildren ¶
NextSkippingChildren returns the next node in document order, but ignores the children of the passed in node. Will iterate upwards until it finds a next node, or hits the root node (which would return nil).
func PrependAttribute ¶
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 RemoveAllChildren ¶
RemoveAllChildren removes all children from node n.
func RemoveAttribute ¶
RemoveAttribute removes the given attribute from node n. If it doesn't exist, this does nothing.
func RemoveNode ¶
RemoveNode removes the node and adjusts the Node pointer to continue iterating over the remaining tree nodes. Returns the removed node.
func SetAttribute ¶
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.
Types ¶
This section is empty.