Programming Kotlin - XML Builder output not right (page 265)

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 Matz

Please correct me if I am wrong.

Thanks.

Hi Eich,

Thank you for the note. I apologize, looks like the xml output was suppressed and I am not able to see the output that you are seeing.

I just ran the code and it seems to produced the desired output without the extra argument.

Regards,

Venkat

Hi Sir,

Yes, XML markup is stripped off here.
Thanks for the prompt response, anyway. Should be something to do with local setup of my IntelliJ.

Regards,
Harry