Suppose I have an XML document stored as an Anti-XML Elem
:
val root : Elem = <foo attr="val"> <bar/> </foo>
. I want to add <baz>blahblahblah</baz>
to the root as a child, specifying
val modified_root : Elem = <foo attr="val"> <bar/> <baz>blahblahblah</baz> </foo>
For comparison, in Python you can just root.append(foo)
.
I know that I can add (as a native) to Group[Node]
with :+
, but this is not what I want:
<foo attr="val"> <bar/> </foo> <baz>blahblahblah</baz>
How to add it as the last child <foo>
? Looking at the documentation , I see no obvious way.
Like Scala XML Creation: Adding children to existing nodes , except this question is for anti-XML, not scala.xml
.
source share