From: Axel Etzold Date: 2007-08-10T18:22:00+09:00 Subject: Re: converting xml to MYSQL that reflects the "tag's embedding"? > Dear Ruby guru's, > > Can any of you tell me how to convert xml to SQL? > > The tags of the text I need to convert are linguistic in nature. E.g. > sentence> and the like. > > What I need, is a database that somehow reflects the embedding. Can > this be done? > > > Kind regards, > Robert. > Dear Robert, I think what you need is to identify "brackets of text" starting with something like and ending with etc., then pass these brackets to some variable in Mysql. For Ruby and MySql, see here: http://www.kitebird.com/articles/ruby-mysql.html The finding of the brackets can be done using regular expressions. I've written some code below. You'd still need to choose some convenient variable name for the different types of brackets (sentence,word etc...) Best regards, Axel ---------------------------------------------------------------- class String def find_positions(opening,closing) open_p=[] closing_p=[] temp=self.dup while opening.match(temp) ref=opening.match(temp) open_p<clb}).max open_p=open_p-[opb] brackets<<[opb,clb] } return brackets.sort{|x,y| x[0]<=>y[0]} end def find_brackets_text(opening,closing) pos_array=self.find_positions(opening,closing) text=[] p 'positions of brackets in the text' p pos_array pos_array.each{|op,cl| p 'opcl' p op p cl text</,/<\/s>/) p c -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail