我希望看到使用http://anti-xml.org而不是 Scala XML 重写波纹管脚本。
这是第 10 章的节选。Scala 中的 Herding XML - http://ofps.oreilly.com/titles/9780596155957/HerdingXMLInScalaDSLs.html
// code-examples/XML/reading/pattern-matching-script.scala
import scala.xml._
val someXML =
<sammich>
<bread>wheat</bread>
<meat>salami</meat>
<condiments>
<condiment expired="true">mayo</condiment>
<condiment expired="false">mustard</condiment>
</condiments>
</sammich>
someXML match {
case <sammich>{ingredients @ _*}</sammich> => {
for (cond @ <condiments>{_*}</condiments> <- ingredients)
println("condiments: " + cond.text)
}
}
谢谢