Skip to content

Instantly share code, notes, and snippets.

@bdarcus
Created May 26, 2009 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdarcus/118263 to your computer and use it in GitHub Desktop.
Save bdarcus/118263 to your computer and use it in GitHub Desktop.
# scala has elegant xml parsing baked in
import scala.xml._
# load the xml file
val style = XML.loadFile("apa.csl")
# get the title
# note: while the parser is namespace-aware, it still returns a result
(style \\ "title").text
# access the macros
val macros = style \\ "macro"
# question: how many are there?
macros.length
# answer: 13
# print the macro names
macros.foreach(macro => println(macro \\ "@name"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment