Suppose I have an XML document stored as an Anti-XML Elem
:
val root : Elem =
<foo attr="val">
<bar/>
</foo>
. I want to append <baz>blahblahblah</baz>
to the root element as a child, giving
val modified_root : Elem =
<foo attr="val">
<bar/>
<baz>blahblahblah</baz>
</foo>
For comparison, in Python you can just root.append(foo)
.
I know I can append (as a sibling) to a Group[Node]
using :+
, but that's not what I want:
<foo attr="val">
<bar/>
</foo>
<baz>blahblahblah</baz>
How do I append it as the last child of <foo>
? Looking at the documentation I see no obvious way.
Similar to Scala XML Building: Adding children to existing Nodes, except this question is for Anti-XML rather than scala.xml
.