I\'m learning scala, and I\'m looking to update a nested node in some xml. I\'ve got something working but i\'m wondering if its the most elegant way.
I have some xm
Scales Xml provides tools for "in place" edits. Of course its all immutable but here's the solution in Scales:
val subnodes = top(xml).\*("subnode"l).\*("version"l)
val folded = foldPositions( subnodes )( p =>
Replace( p.tree ~> "2"))
The XPath like syntax is a Scales signature feature, the l after the string specifies it should have no namespace (local name only).
foldPositions iterates over the resulting elements and transforms them, joining the results back together.