Created
March 23, 2011 11:34
-
-
Save kings13y/882974 to your computer and use it in GitHub Desktop.
Simple example of XML pattern matching
This file contains hidden or 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
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