From: "mythpills P." Date: 2011-12-01T15:02:08+09:00 Subject: break from a loop which is run on a xml how do i loop through a xml and break when i find the node with a specific value..really struggling to break out of a xml loop..most of the iterators just loop but cannot be break - ed please help me with this for e.g. this is d code where i find the files in a dir & check d earlier time stamp for each file which is saved in a xml & do a comparison for each Find.find('./'){|path| if path != './abcd.rb' if ! File::directory? ( path ) modtime = File.mtime(path) xmldoc.elements.each("course/file"){ |element| oldtime = Time.parse(element.attributes["modified"]) if modtime > oldtime $changed = "yes" break else $changed = "no" end } newfile = course.add_element 'file', {'version'=>'2.0', 'modified'=> modtime, 'download'=>$changed} newfile.text = path[2,path.length] end end } this is the sample xml.. xyzw.pdf content/banner/t1-st_1.swf content/t1/st_1/page1.swf content/t1/st_2/page1.swf content/t1/st_2/page2.swf content/t1/st_2/page3.swf -- Posted via http://www.ruby-forum.com/.