From: "Иван Бишевац" Date: 2012-09-06T19:20:09+09:00 Subject: Re: Parsing through downloaded html --047d7b33d51845a26804c905d594 Content-Type: text/plain; charset=UTF-8 I've done similar job recently. I've copied part of code so look at it maybe it could help you: require 'nokogiri' require 'spreadsheet' class XmlParsing def test row = 0 column = 0 book = Spreadsheet::Workbook.new sheet = book.create_worksheet Dir.chdir("xml") puts Dir.pwd Dir.glob("*.xml") do |file| f = File.open(file) doc = Nokogiri::XML(f) fullname_node = doc.at_xpath("//full_name") sheet[row,column] = fullname_node.content f.close row += 1 end book.write 'spreadsheet.xls' end end xml = XmlParsing.new xml.test I'm not sure if it works because I've deleted some code from original script but this is general idea. It script parses xml document and puts information into excel. Plus you need spreadsheet gem. You can install it with: sudo gem install spreadsheet. Or there is better way to do it. Make one file named Gemfile and put this content into it: source 'https://rubygems.org' gem 'nokogiri' gem 'spreadsheet' Save file and go to console cd to dir where Gemfile is located and run: bundle install This is preferred way to go because there is no need to install gems one by one manually. Instead when you want to run your software on different machine you just invoke bundle install. Hope it helps. 2012/9/6 Sybren Kooistra > Hi Ivan, thanks. > > I'm doing my best here, and I do search before I post. I was just > checking if I was working in the right direction. Excel library is step > two. > > -- > Posted via http://www.ruby-forum.com/. > > --047d7b33d51845a26804c905d594 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I've done similar job recently. I've copied part of code so look at= it maybe it could help you:
require 'nokogiri'
= require 'spreadsheet'

class XmlParsing
=C2=A0 def test
=C2=A0 =C2=A0 row =3D 0
=C2=A0 =C2= =A0 column =3D 0
=C2=A0 =C2=A0 book =3D Spreadsheet::Workbook.new=
=C2=A0 =C2=A0 sheet =3D book.create_worksheet
=C2=A0 = =C2=A0=C2=A0
=C2=A0 =C2=A0 Dir.chdir("xml")
=C2=A0 =C2=A0 puts Dir.pwd
=C2=A0 =C2=A0 Dir.glob("*.xml") do |file|
=C2=A0 = =C2=A0 =C2=A0 f =3D File.open(file)
=C2=A0 =C2=A0 =C2=A0 doc =3D = Nokogiri::XML(f)
=C2=A0 =C2=A0 =C2=A0 fullname_node =3D doc.at_xp= ath("//full_name")
=C2=A0 =C2=A0 =C2=A0 sheet[row,colum= n] =3D fullname_node.content
=C2=A0 =C2=A0 =C2=A0 f.close
=C2=A0 =C2=A0 =C2=A0 row +=3D 1=
=C2=A0 =C2=A0 end
=C2=A0 =C2=A0 book.write 'spread= sheet.xls'
=C2=A0 end
end

= xml =3D XmlParsing.new
xml.test


I'm not sure if it works because I've del= eted some code from original script but this is general idea. It script par= ses xml document and puts information into excel.

Plus you need spreadsheet gem. You can install it with:
sudo gem = install spreadsheet.

Or there is better way to do = it. Make one file named Gemfile and put this content into it:
source 'https://rubygems.org&= #39;

gem 'nokogiri'
gem 'spr= eadsheet'

Save file and go to console cd= to dir where Gemfile is located and run:
bundle install

This is preferred way to go be= cause there is no need to install gems one by one manually. Instead when yo= u want to run your software on different machine you just invoke bundle ins= tall.

Hope it helps.

2012= /9/6 Sybren Kooistra <lists@ruby-forum.com>
Hi Ivan, thanks.

I'm doing my best here, and I do search before I post. I was just
checking if I was working in the right direction. Excel library is step
two.

--047d7b33d51845a26804c905d594--