FilterChildNodes removes all child nodes of type *Node that do not satisfy the given predicate function.
(pred func(child *Node) bool)
| 41 | // FilterChildNodes removes all child nodes of type *Node |
| 42 | // that do not satisfy the given predicate function. |
| 43 | func (n *Node) FilterChildNodes(pred func(child *Node) bool) { |
| 44 | n.Children = slices.DeleteFunc(n.Children, func(child Token) bool { |
| 45 | cn, ok := child.(*Node) |
| 46 | if !ok { |
| 47 | return false |
| 48 | } |
| 49 | return !pred(cn) |
| 50 | }) |
| 51 | } |
| 52 | |
| 53 | // WriteTo writes the XML representation of the node and its children to the provided writer. |
| 54 | func (n *Node) WriteTo(w TokenWriter) error { |
no outgoing calls
no test coverage detected