Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import xml._
  2.  
  3. case class Menu(name: List[String])
  4. case class BreakFastMenu(food: List[Menu], price: List[Menu], des: List[Menu], cal: List[Menu])
  5.  
  6. def toMenu(node : Node): Menu = {
  7. val menuChart = (node "food")
  8. Menu(menuChart)
  9. }
  10.  
  11. def toBreakFastMenu(node: Node): BreakFastMenu = {
  12. val name = (node "name").map(toMenu).toList
  13. val price = (node "price").map(toMenu).toList
  14. val des = (node "description").map(toMenu).toList
  15. val cal = (node "calories").map(toMenu).toList
  16. BreakFastMenu(name, price, des, cal)
  17. }
  18.  
  19. val menuXML = XML.loadFile("simple.xml")
  20. val food = (menuXML "food").map(toMenu).toArray
  21. food.foreach(println)
  22.  
  23. MenuXML.scala:9: error: type mismatch;
  24. found : scala.xml.NodeSeq
  25. required: List[String]
  26. Menu(menuChart)
  27. ^
  28. one error found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement