2

I'm experimenting with Ruby and Nokogiri.

I've figured out how to open a local html document and select nodes by classname:

require 'rubygems'                                                                                               
require 'nokogiri'                                                                                               

doc = Nokogiri::HTML(open("file"))                                                                          


puts doc.css('a.target') 

How then do I dump the document without the nodes I've selected for?

bob
  • 753
  • 4
  • 15
  • 27
  • Possible duplicate of [How do I remove a node with Nokogiri?](https://stackoverflow.com/questions/1708504/how-do-i-remove-a-node-with-nokogiri) – aridlehoover Mar 06 '19 at 07:33

1 Answers1

4

Should be:

doc.css('a.target').remove
puts doc.at('html').to_s
pguardiario
  • 53,827
  • 19
  • 119
  • 159