goquery, how to remove child

171 views
Skip to first unread message

Tong Sun

unread,
Jun 15, 2016, 11:38:56 PM6/15/16
to golang-nuts
How to remove child nodes in goquery?

I'm trying 3 different ways to remove child nodes in my sample code,
as I can't quite figure it out from the doc: 

 titleHtml, _ = title.RemoveFiltered("a").Html()
 locationHtml
, _ = location.RemoveClass("date-posted").Html()
 descriptionHtml
, _ = description.Find("div").Remove().Html()


However, none of them is what I'm expecting. Basically all three contains sub nodes that I want to remove, and I want the end result to be the html without the removed nodes. 

Check out the full source code, or its execution result for details. 

Thanks


Reply all
Reply to author
Forward
0 new messages