I wanted a function that would add me a new Element in the end of an existing one and so I looked for a function to do that like this one:
def d(x: xml.Node, n: xml.Node) =
x match {case <a>{l @ _*}</a> => <a>{l}{n}</a>}
But the problem is that the old Element has attributes and with this function I lose them, how can I keep the attributes in all my Elements?
Result:
scala> d(<a foo="bar"><b>b1</b></a>, <b>b2</b>)
res5: scala.xml.Elem = <a><b>b1</b><b>b2</b></a>
Expected result:
scala> d(<a foo="bar"><b>b1</b></a>, <b>b2</b>)
res5: scala.xml.Elem = <a foo="bar"><b>b1</b><b>b2</b></a>
No comments:
Post a Comment