This topic contains 1 reply, has 2 voices, and was last updated by  Casey Trauer 4 years, 3 months ago.

Unable to split child nodes

  • Hi,

    I have a requirement where my client is sending data over HTTP Api in the format


    I need to send this XML data to our webservice in the same XML format.

    So for mapping I created a template

    template= <appointment>

    During mapping I am using setinner to set the value of template with the incoming XMLMsg. like below
    local traverse(template,XMLMsg)
    for i=1, XMLMsg.appointments:childCount(‘appointment’) do


    return Xml

    And then I format the result like below.

    function formatResult(Xml)

    — If XML, then concatenate results with table.concat
    local Output = “<appointments>\n”..table.concat(Xml)..”\n</appointments>”
    return Output, ‘text/xml’

    But when I checked the return output from formatresult, I am getting


    I am unable to split the childs “</appointment><appointment>” and should be separated by a newline. Can someone help me on how to achieve this.


    I am reading two core challenges here:
    1. You are mapping the values from one node over and over.
    2. You are not happy with the formatting of the xml.

    The first thing I would try is setting an index in your for loop:


    As for the formatting, check the documentation for the table.concat function. You can pass a separator into the function, probably like this:


    Hope that helps.

    Casey Trauer,
    Director, Client Education

You must be logged in to reply to this topic.