T
ted
Hi,
I'm new to Ruby and can't figure out why REXML isn't returning the elements
in the order they appear in the document. Here's my code and the document.
Any help appreciated.
Thanks,
Ted
#==============================
# ruby
#==============================
xml = REXML:ocument.new(File.open("test.html"));
xml.elements.each("//span[@class='c5']") do |element|
puts element
end
#==============================
# the "test.html" file
#==============================
<html>
<body>
<a name="1"/>
<table><tr><td><span class="c5"><b>1st Title</b></span></td></tr></table>
<a name="2"/>
<table><tr><td><span class="c5"><b>2nd Title</b></span></td></tr></table>
<a name="3"/>
<table><tr><td><span class="c5"><b>3rd Title</b></span></td></tr>
</table>
</body>
</html>
I'm new to Ruby and can't figure out why REXML isn't returning the elements
in the order they appear in the document. Here's my code and the document.
Any help appreciated.
Thanks,
Ted
#==============================
# ruby
#==============================
xml = REXML:ocument.new(File.open("test.html"));
xml.elements.each("//span[@class='c5']") do |element|
puts element
end
#==============================
# the "test.html" file
#==============================
<html>
<body>
<a name="1"/>
<table><tr><td><span class="c5"><b>1st Title</b></span></td></tr></table>
<a name="2"/>
<table><tr><td><span class="c5"><b>2nd Title</b></span></td></tr></table>
<a name="3"/>
<table><tr><td><span class="c5"><b>3rd Title</b></span></td></tr>
</table>
</body>
</html>