From: Soichi Ishida Date: 2012-10-31T14:20:05+09:00 Subject: Nokogiri Xpath: need to write "\n" for every table element Rails 1.9.3 For http://en.wikipedia.org/wiki/List_of_airports_by_IATA_code:_A I would like to make a list of airport names using Nokogiri. The following code seems to work but it does not insert "\n" as I wish. Can you tell me why? require 'open-uri' require 'nokogiri' test_url = "http://en.wikipedia.org/wiki/List_of_airports_by_IATA_code:_A" url_list_file = "list_page_url.txt" test_xpath = "//tr" output_file = "list_airport_names_wiki_url.txt" test = Nokogiri::HTML(open(test_url)) File.open(output_file, "a") {|f| test.xpath(test_xpath).each do |e| f.write e.xpath("//td[3]/a").text + "\n" #### HERE!!! #### end } -- Posted via http://www.ruby-forum.com/.