Created
May 26, 2009 20:08
-
-
Save bdarcus/118263 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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