scala> val xml: scala.xml.Elem =
|
|
| -
| 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
|
|
|
scala> val firstItem = xml \\ "item" take 1
firstItem: scala.xml.NodeSeq =
NodeSeq(-
Invisibility Cream
14.50
Makes you invisible
)
scala> xml \\ "price" map (_.text) foreach println
14.50
23.99
4.95
3.56
scala> val names = (xml \\ "name").toArray
names: Array[scala.xml.Node] = Array(Invisibility Cream, Levitation Salve, Blork and Freen Instameal, Grob winglets)