I want to produce an XML document from another, filtering subnodes that match a s开发者_开发技巧pecified criterion. How should I do that?
You can use RuleTransformer from scala.xml.transform.
Suppose you have action attribute with "remove" value
val removeIt = new RewriteRule {
override def transform(n: Node): NodeSeq = n match {
case e: Elem if (e \ "@action").text == "remove" => NodeSeq.Empty
case n => n
}
}
new RuleTransformer(removeIt).transform(yourXML)
精彩评论