The code given in the book for XMLBuilder DLS returns the below output - not the one given in the book:
Eich
Gosling
Matz
The below else part of the toString method -
“”"$indent<$name$attributesValues>
|${children.joinToString("\n") { it.toString(indentation + DEPTH) }}
|$indent</$name>""".trimMargin()
has to be changed a bit, with joinToString taking a prefix of a new line (\n) along with the new line separator, like below -
“”"$indent<$name$attributesValues>
|${children.joinToString("\n")("\n") { it.toString(indentation + DEPTH) }}
|$indent</$name>""".trimMargin()
To get the necessary output:
Eich Gosling MatzPlease correct me if I am wrong.
Thanks.