Added Node.SetValue(string) method.
SetValue replaces all children of the current node with a single NT_TEXT node and sets its Value to the given parameter. This lets us replace node values before writing out the document.
This commit is contained in:
parent
745ca85455
commit
17e1b69620
2 changed files with 82 additions and 0 deletions
7
node.go
7
node.go
|
@ -66,6 +66,13 @@ func (this *Node) GetValue() string {
|
|||
return res
|
||||
}
|
||||
|
||||
func (this *Node) SetValue(val string) {
|
||||
t := NewNode(NT_TEXT)
|
||||
t.Value = string([]byte(val))
|
||||
t.Parent = this
|
||||
this.Children = []*Node{t} // brutally replace all other children
|
||||
}
|
||||
|
||||
// Get node value as string
|
||||
func (this *Node) S(namespace, name string) string {
|
||||
foundNode := rec_SelectNode(this, namespace, name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue