This is a very gentle introduction to Galax. 1. Download mondial-3.0.xml from http://www.cs.washington.edu/research/xmldatasets. Download galax from http://db.bell-labs.com/galax 2. Create two files q1.xq and q2.xq as follows: q1.xq: { for $x in document("mondial-3.0.xml")/mondial/country//city/name/text() return { $x } } q2.xq: { for $x in document("mondial-3.0.xml")/mondial/country[@name="Peru"]/province[count(city)>1]/@name return { fn:string($x) } } 3. Type: galax q1.xq In a few seconds galax will print the result for you. In this case it's the list of all city names in the database. Notice that cities occur either under country, or under province. In order to get both we used country//city. 4. Now try galax q2.xq You are getting the names of all provinces in Peru with at least two cities. 5. Finally, try: galax q2.xq > myfile.xml This creates myfile.xml with your result.