Merge pull request #12 from mattkanwisher/master
Adding new helper methods to make things more useful
This commit is contained in:
		
						commit
						089e94f17d
					
				
					 1 changed files with 35 additions and 1 deletions
				
			
		
							
								
								
									
										34
									
								
								node.go
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								node.go
									
										
									
									
									
								
							| 
						 | 
					@ -395,6 +395,40 @@ func rec_SelectNodes(cn *Node, namespace, name string, list *[]*Node, recurse bo
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *Node) RemoveNameSpace() {
 | 
				
			||||||
 | 
						this.Name.Space = ""
 | 
				
			||||||
 | 
						//	this.RemoveAttr("xmlns") //This is questionable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range this.Children {
 | 
				
			||||||
 | 
							v.RemoveNameSpace()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *Node) RemoveAttr(name string) {
 | 
				
			||||||
 | 
						for i, v := range this.Attributes {
 | 
				
			||||||
 | 
							if name == v.Name.Local {
 | 
				
			||||||
 | 
								//Delete it
 | 
				
			||||||
 | 
								this.Attributes = append(this.Attributes[:i], this.Attributes[i+1:]...)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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…
	
	Add table
		Add a link
		
	
		Reference in a new issue