From: Robert Klemme Date: 2009-03-27T01:53:22+09:00 Subject: Re: basic xml parsing question 2009/3/26 Geo Cooper : > I have a a file that I want to put the contents into a sqlite database. > This file is locally saved now, but will eventually be sent by remote > machines for  collecting the data from. I will not have to retrieve the > documents, but I will have to figure out how to accept them when they > are sent to me. I have read up a bit on REXML and Nokogiri, but am not > sure where/how to get started. Well, using REXML you have two options 1. use REXML's DOM parsing, i.e. let it read in the whole file and create an XML DOM tree in memory. Then you can traverse that DOM tree, for example using XPath expressions and fill the DB while you do the traversal. 2. use REXML's PUSH or PULL parsing and fill the DB while you receive the parsing events. In this scenario you will have to keep some state (e.g. information about the parent "callsummary" of a "calldetail") yourself. The second approach is usually more efficient because you never need the whole document in memory but it is also a bit more complex to implement. > If someone can give me some pointers on where to start, that would be > great. Some links http://www.germane-software.com/software/rexml/docs/tutorial.html http://www.w3schools.com/xpath/ http://www.zvon.org/xxl/XPathTutorial/General/examples.html > Below is a partial sample of what I'm trying to parse. The database > tables correspond to the record names. What record names? Do you mean XML tags? Cheers robert -- remember.guy do |as, often| as.you_can - without end