From: Phrogz Date: 2009-03-19T13:47:40+09:00 Subject: Re: how to output two data elements from simple XML On Mar 18, 5:52 pm, Michael Malone wrote: > XPath.match(doc, "//Field FieldId").each do |e| >    puts "#{e.attribute('Path').to_s.gsub!('/Docs/Animal/', '')} > #{e.attribute('Attribute')}" > end > > Yes, removing /Docs/Animal/ like that isn't a brilliant idea, but it works. Perhaps slightly better: last_path_entry = e.attribute('Path').value[ %r{[^/]+$} ] or: last_path_entry = e.attributes['Path'][ %r{[^/]+$} ] or, if it really can be treated as a file path: last_path_entry = File.basename( e.attributes['Path'] )