#lang at-exp racket (define input @~a{
Invisibility Cream 14.50 Makes you invisible Levitation Salve 23.99 Levitate yourself for up to 3 hours per application
Blork and Freen Instameal 4.95 A tasty meal in a tablet; just add water Grob winglets 3.56 Tender winglets of Grob. Just add water
}) (require xml xml/path) (define data (xml->xexpr ((eliminate-whitespace '(inventory section item)) (read-xml/element (open-input-string input))))) ;; Retrieve the first "item" element (displayln (xexpr->string (se-path* '(item) data))) ;; => Invisibility Cream ;; Perform an action on each "price" element (print it out) (printf "Prices: ~a\n" (string-join (se-path*/list '(item price) data) ", ")) ;; => Prices: 14.50, 23.99, 4.95, 3.56 ;; Get an array of all the "name" elements (se-path*/list '(item name) data) ;; => '("Invisibility Cream" "Levitation Salve" "Blork and Freen Instameal" "Grob winglets")