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:
Guido Witmond 2015-01-05 17:13:46 +01:00
parent 745ca85455
commit 17e1b69620
2 changed files with 82 additions and 0 deletions

View file

@ -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)