object Test { import scala.xml.{Node,HasKeyValue} def domatch(x:Node): Node = { val hasBar = new HasKeyValue("bar") x match { case Node("foo", hasBar(z), _*) => z case _ => null } } def main(args: Array[String]): Unit = { println(domatch()) println(domatch()) // // assert(domatch().toString == "baz") // assert(domatch() == null)//, domatch()) } }