I\'m writing a tool to update some xml files (pom.xml in this case) with scala because the effort it would take in java is significantly higher than (in theory) it is with s
You really should take a look at other questions on Stack Overflow about modifying XML. Look at the "Related" links to the right.
Here:
scala>
| foo
| bar
| 1.0-SNAPSHOT
|
res0: scala.xml.Elem =
foo
bar
1.0-SNAPSHOT
scala> new scala.xml.transform.RewriteRule {
| override def transform(n: Node): Seq[Node] = n match {
| case {v} if v.text contains "SNAPSHOT" => {v.text.split("-")(0)}
| case elem: Elem => elem copy (child = elem.child flatMap (this transform))
| case other => other
| }
| } transform res0
res9: Seq[scala.xml.Node] =
foo
bar
1.0