這個工程:階節點的比賽情況
<a>apple</a>
node match {
case <a>{contents}</a> => "It's an a: "+ contents
case _ => "It's something else."
}
我怎麼能更改這個例子,所以它僅匹配與標籤「a」和屬性ID = 2的節點: 東西如下:
<a id="2">apple</a>
node match {
case <a id="2">{contents}</a> => "It's an a: "+ contents
case _ => "It's something else."
}
但這不能編譯。
請參閱[這個問題](http://stackoverflow.com/questions/2610191/scala-xml-pattern-matching-and-attributes)。 – Philippe 2012-02-28 14:42:25
看看這個[文章] [1] [1]:http://stackoverflow.com/questions/2610191/scala-xml-pattern-matching-and-attributes – Eduardo 2012-02-28 14:45:52