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..
<course name='' uniqueID='' serverURL='' >
<file version='1.0' modified='2011-11-30 16:37:23 +0530' download='no'>
xyzw.pdf
</file>
<file version='1.0' modified='2011-11-07 02:30:01 +0530' download='no'>
content/banner/t1-st_1.swf
</file>
<file version='1.0' modified='2011-11-07 02:30:01 +0530' download='no'>
content/t1/st_1/page1.swf
</file>
<file version='1.0' modified='2011-11-07 02:30:02 +0530' download='no'>
content/t1/st_2/page1.swf
</file>
<file version='1.0' modified='2011-11-07 02:30:02 +0530' download='no'>
content/t1/st_2/page2.swf
</file>
<file version='1.0' modified='2011-11-07 02:30:03 +0530' download='no'>
content/t1/st_2/page3.swf
</file>
</course>
--
Posted via http://www.ruby-forum.com/.