Skip to content

Instantly share code, notes, and snippets.

@kings13y
Created March 23, 2011 11:34
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 kings13y/882974 to your computer and use it in GitHub Desktop.
Save kings13y/882974 to your computer and use it in GitHub Desktop.
Simple example of XML pattern matching
import scala.xml._
val someXML = <a><b name="nameB1">valueB1</b><b name="nameB2">valueB2</b></a>
someXML match {
case <a>{b @ _* }</a> => for(theB <- b) println("MANUAL PATTERN MATCHING: " + theB \ "@name")
}
for(theB <- (someXML \\ "b")) println("BUILT IN XML SUPPORT: " + theB \ "@name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment