I wasn’t sure about my questions name. I have an HTML page I got using nokogiri. Now I want to cut some tags off that page. I tried using ruby’s delete method after converting the html to a string – Though it deletes all the letters I entered. The best result i got was using .gsub('<stuff>', '') though it still leaves some space. Is it possible to actually cut stuff of a string? specific pharses?
Another question – Can I remove spaces?
what I done so far :
doc = Nokogiri::HTML(open("http://www.example.com/"))
tester = doc.css(".example").to_s.gsub('<div class="example">', '')
I’d suggest trying to do it at the xml tree level rather than string editing.
I think the nokogiri api gives you some tools for doing this.
Another approach might be selecting the data you want, with css or xpath, rather than deleting the parts you don’t want?
There’s also an xpath function for normalising space in strings, there’s an example in this question
Some nokogiri help: