VMh
VMh

Reputation: 1340

CsQuery Remove not working

Isn't this supposed to remove all Divs? It is not working for me.

 CQ cq = CQ.CreateFromUrl("http://www.ebay.com");
 CQ newCq = cq["body"].Remove("div");
 string htmlCode = newCq.Render();  //The rendered code shows Divs present

Thanks

Upvotes: 0

Views: 449

Answers (1)

Jamie Treworgy
Jamie Treworgy

Reputation: 24344

When you pass a parameter to Remove it's a filter, not a context-type selector, see http://api.jquery.com/remove/

So this code is only going to match div elements that are directly members of the selection, which only has one member, body.

To remove all divs that are within body:

CQ newCq = cq["body div"].Remove();

Upvotes: 3

Related Questions