HasAttr determines if an attribute exists.
(key string)
| 409 | |
| 410 | // HasAttr determines if an attribute exists. |
| 411 | func (n *Node) HasAttr(key string) bool { |
| 412 | name := newXMLName(key) |
| 413 | for _, attr := range n.Attr { |
| 414 | if attr.Name == name { |
| 415 | return true |
| 416 | } |
| 417 | } |
| 418 | return false |
| 419 | } |
| 420 | |
| 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. |