# -*- ruby -*-
#
# '//', '**', '**[]'
#

require 'xtemplate'

text = <<EOF
<?xml version="1.0"?>
<members>
  <name id="//name">
  </name>

  <name id="/**/name">
  </name>

  <name id="/**[name and age and age&gt;25]/name">
  </name>
</members>
EOF

data = {
  "name"    => "name0",
  "members" => [
    {"name" => "name1", "age" => 27},
    {"name" => "name2", "age" => 22},
    {"name" => "name3"},
  ],
  "staff" => {
    "staff1" => [
       {"name" => "name4", "age" => 24},
       {"name" => "name5", "age" => 27},
    ],
    "staff2" => [
       {"name" => "name6", "age" => 28},
       {"name" => "name7"},
    ],
  }
}

print XTemplate::XMLTemplate.new(text).expand(data)
