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