I have block of code:
object XmlExample {
def main(args: Array[String]): Unit = {
val someXml =
<books>
<book title="The Woman in White">
<author>Wilkie Collins</author>
</book> <book title="Great Expectations">
<author>Charles Dickens</author>
</book>
</books>
println("The xml object is of type: " + someXml.child)
}
}
I want check if node <c1>does not exist as its child, then I added it like <c1>Null</c1>
I'm not sure to have fully understood does not exist as its child ... or what you exactly mean by I added it but here's my straight answer for adding optionally a direct child of books :
this works like:
should normally print:
Hope it helps. Don't hesitate whenever c1 isn't at the place you expected or something else.