node

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package node provides helper functions to work with queryxml.Node pointers.

All functions explicitly handle nil nodes and therefore allow for deep nesting of these function calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendChild

func AppendChild(p, c *xmlquery.Node)

AppendChild appends the child c to the parent p. Both given nodes must not be null.

func Data

func Data(node *xmlquery.Node) string

Data returns the data for the node or the empty string if the node in nil.

func Delete

func Delete(n *xmlquery.Node)

Delete removes the given node from its tree. The given node must not be nil.

func FirstChild

func FirstChild(node *xmlquery.Node) *xmlquery.Node

FirstChild returns the first child of the node or nil if the node is nil.

func LookupAttr

func LookupAttr(node *xmlquery.Node, key xml.Name) (string, bool)

LookupAttr looks up an attribute by its key and if the key was found.

func LookupAttrAsFloat

func LookupAttrAsFloat(node *xmlquery.Node, key xml.Name) (float64, bool)

LookupAttrAsFloat looks up an attribute by its key and interprets it as a float.

func LookupAttrAsInt

func LookupAttrAsInt(node *xmlquery.Node, key xml.Name) (int, bool)

LookupAttrAsInt looks up an attribute by its key and interprets it as an int.

func Parent

func Parent(node *xmlquery.Node) *xmlquery.Node

Parent returns the node's parent or nil if the node is nil.

func PrependChild

func PrependChild(p, c *xmlquery.Node)

PrependChild prepends the child c to the parent p. Both given nodes must not be null.

func PrependSibling

func PrependSibling(n, s *xmlquery.Node)

PrependSibling prepends to the node n a new sibling s. Both given nodes must not be null.

func PrettyPrint added in v0.0.22

func PrettyPrint(node *xmlquery.Node, prefix, indent string) string

PrettyPrint pretty prints the given node and returns it. If the given node is nil, an empty string is returned.

func Query

func Query(node *xmlquery.Node, expr string) (*xmlquery.Node, error)

Query calls xmlquery.Query. If the given node is nil, an emtpy node list is returned.

func QueryAll

func QueryAll(node *xmlquery.Node, expr string) ([]*xmlquery.Node, error)

QueryAll calls xmlquery.QueryAll. If the given node is nil, an empty node list is returned.

func SetAttr

func SetAttr(node *xmlquery.Node, attr xml.Attr)

SetAttr sets or overwrites the attribute in the given node. If the node contains the given attribute is updated with the value. Otherwise a new attribute is appended to the node's attribute list.

Types

This section is empty.

Jump to

Keyboard shortcuts

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