MCPcopy Create free account
hub / github.com/antchfx/xmlquery / SetAttr

Method SetAttr

node.go:423–432  ·  view source on GitHub ↗

SetAttr allows an attribute value with the specified name to be changed. If the attribute did not previously exist, it will be created.

(key, value string)

Source from the content-addressed store, hash-verified

421// SetAttr allows an attribute value with the specified name to be changed.
422// If the attribute did not previously exist, it will be created.
423func (n *Node) SetAttr(key, value string) bool {
424 name := newXMLName(key)
425 for i, attr := range n.Attr {
426 if attr.Name == name {
427 n.Attr[i].Value = value
428 return true
429 }
430 }
431 return AddAttr(n, key, value)
432}
433
434// RemoveAttr removes the attribute with the specified name.
435func (n *Node) RemoveAttr(key string) bool {

Callers 1

TestSetAttrFunction · 0.80

Calls 2

newXMLNameFunction · 0.85
AddAttrFunction · 0.85

Tested by 1

TestSetAttrFunction · 0.64