Scala XML Building: Adding children to existing Nodes

前端 未结 9 1270
感动是毒
感动是毒 2020-12-15 04:42

I Have an XML Node that I want to add children to over time:

val root: Node = 

But I cannot see methods such as

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 05:18

    Since scala 2.10.0 the instance constructor of Elem has changed, if you want use naive solution written by @Daniel C. Sobral, it should be:

    xmlSrc match {
      case xml.Elem(prefix, label, attribs, scope, child @ _*) =>
           xml.Elem(prefix, label, attribs, scope, child.isEmpty, child ++ ballot : _*)
      case _ => throw new RuntimeException
    }
    

    For me, it works very good.

提交回复
热议问题