Documentation
¶
Index ¶
- func AddAttrSafe(node *xmlquery.Node, key, value string) bool
- func ChildNodes(node *xmlquery.Node) ([]*xmlquery.Node, error)
- func Children(node *xmlquery.Node) []*xmlquery.Node
- func GetAttrSafe(node *xmlquery.Node, key string) (string, bool)
- func GetAttributeNameFromExpression(expr string) (string, bool)
- func HasAttr(node *xmlquery.Node, key string) bool
- func HasAttributes(node *xmlquery.Node) bool
- func IsAttributeExpression(expr string) bool
- func IsElementLike(node *xmlquery.Node) bool
- func LoadXML(filename string) (*xmlquery.Node, error)
- func NormalizeXPath(expr string) string
- func ParseXmlStr(xmlStr string) (*xmlquery.Node, error)
- func RemoveAttrSafe(node *xmlquery.Node, key string) bool
- func RemoveAttributeFromXPath(expr string) (string, bool)
- func RemoveFromTreeSafe(node *xmlquery.Node) bool
- func SaveXML(doc *xmlquery.Node, filename string) error
- func Serialize(doc *xmlquery.Node) (string, error)
- func SetAttrSafe(node *xmlquery.Node, key, value string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAttrSafe ¶
AddAttrSafe adds an attribute to the node only if it does not already exist.
Returns true if the attribute was added, false if it already exists.
func ChildNodes ¶
ChildNodes returns a slice of all direct child nodes of the given node, excluding attributes, text, comments, and char data. Returns an error if the node type does not support child nodes.
func Children ¶
Children returns a slice of all direct child nodes of the given node. This includes all node types that are children, without filtering.
func GetAttributeNameFromExpression ¶
GetAttributeNameFromExpression extracts the attribute name from the expression.
func HasAttributes ¶
HasAttributes checks if the node has any attributes.
func IsAttributeExpression ¶
IsAttributeExpression checks if the expression is targeting an attribute.
func IsElementLike ¶
IsElementLike returns true if the node type supports child nodes.
func NormalizeXPath ¶
NormalizeXPath ensures that the XPath expression starts with a double slash.
func ParseXmlStr ¶
ParseXmlStr parses an XML string.
func RemoveAttrSafe ¶
RemoveAttrSafe removes an attribute from a node if it exists.
Returns true if the attribute was removed, false otherwise.
func RemoveAttributeFromXPath ¶
RemoveAttributeFromXPath trims the trailing attribute selector from an XPath expression, if present. Example: "/root/item/@id" → "/root/item"
func RemoveFromTreeSafe ¶
RemoveFromTreeSafe removes a node and its subtree from the document tree it is in. If the node is the root of the tree, then it's a no-op.
Returns true if the node was removed, false if it was not.
Types ¶
This section is empty.