require 'xtemplate/xml'

doc = XTemplate::XMLDocument.new <<EOF
<?xml version="1.0"?>
<members>
  <member uid="1">
     <name>name1</name>
     <age>21</age>
  </member><member uid="2">
     <name>name2</name>
     <age>23</age>
  </member><member uid="3">
     <name>name3</name>
     <age>22</age>
  </member><member uid="4">
     <name>name4</name>
     <age>25</age>
  </member>
</members>
EOF

p doc["//name"]
p doc["//age"]
p doc["/members[2]/**/name"]
p doc["//member[age and int(age)&gt;22]/age"]
