weyus
1
All,
If I have the following (assume that xml contains a valid REXML Document
and that the root of the xml is way above any
elements in the
document):
just_rows = xml.elements["//tr[starts_with(@id,
‘xdgDataRow_grid_container_’)]"]
shouldn’t just_rows contain all of the
elements whose id
attributes start_with “xdgDataRow_grid_container_”?
It’s only getting the first one. Do I need to add something to the
XPath to pull all of the
elements under the root?
Thanks,
Wes
weyus
2
Wes G. wrote:
It’s only getting the first one. Do I need to add something to the
XPath to pull all of the elements under the root?
Try :
XPath.each(doc, ‘//tr etc’) do |node|
p node
end
Maybe .elements only returns contiguous matches.
–
Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!
weyus
3
Thanks!
This seems to work well:
just_rows = ‘’
REXML::XPath.each(xml, “//tr[starts_with(@id,
‘xdgDataRow_grid_container_’)]”) {|node| just_rows << node.to_s}
WG