doc, err := html.Parse(strings.NewReader("")) if err != nil { log.Fatal(err) } for c := doc.FirstChild.FirstChild; c != nil; c = c.NextSibling { if c.Type == html.ElementNode && c.Data == "p" { doc.FirstChild.RemoveChild(c) } }Example
Another example
func removeNode(node *html.Node) { if node.Parent == nil { return } node.Parent.RemoveChild(node) }In this example, we define a `removeNode` function that takes a pointer to an `html.Node` object as its argument. The function checks if the node has a parent node and, if it does, it removes the node from its parent using the `RemoveChild` method. This function could be used in a larger program to remove specific nodes from an HTML document.