add some new helper methods
This commit is contained in:
parent
6de2878785
commit
d59371c359
22
node.go
22
node.go
|
@ -27,7 +27,7 @@ var IndentPrefix = ""
|
||||||
|
|
||||||
type Attr struct {
|
type Attr struct {
|
||||||
Name xml.Name // Attribute namespace and name.
|
Name xml.Name // Attribute namespace and name.
|
||||||
Value string // Attribute value.
|
Value string // Attribute value.
|
||||||
}
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
|
@ -395,6 +395,26 @@ func rec_SelectNodes(cn *Node, namespace, name string, list *[]*Node, recurse bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Node) RemoveNameSpace() {
|
||||||
|
this.Name.Space = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Node) SetAttr(name, value string) {
|
||||||
|
for _, v := range this.Attributes {
|
||||||
|
if name == v.Name.Local {
|
||||||
|
v.Value = value
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Add
|
||||||
|
attr := new(Attr)
|
||||||
|
attr.Name.Local = name
|
||||||
|
attr.Name.Space = ""
|
||||||
|
attr.Value = value
|
||||||
|
this.Attributes = append(this.Attributes, attr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Convert node to appropriate []byte representation based on it's @Type.
|
// Convert node to appropriate []byte representation based on it's @Type.
|
||||||
// Note that NT_ROOT is a special-case empty node used as the root for a
|
// Note that NT_ROOT is a special-case empty node used as the root for a
|
||||||
// Document. This one has no representation by itself. It merely forwards the
|
// Document. This one has no representation by itself. It merely forwards the
|
||||||
|
|
Loading…
Reference in New Issue