This topic contains 0 replies, has 1 voice, and was last updated by  pooja 9 months ago.

Read data from lua table and convert incoming data to xml

  • Hi,

    I have to read data from sqlserver database.

    I have converted result returned by query into lua table.

    So i have to map the lua table data into below xml template format

    local xml_template=[[
    <AccessDetail>
    <PersonData>
    <NRIC></NRIC>
    <Name></Name>
    <Status></Status>
    <LastLogin></LastLogin>
    <RolesType>
    <Role>
    <RoleID></RoleID>
    <RoleType></RoleType>
    </Role>
    </RolesType>
    </PersonData>
    </AccessDetail>
    ]]

    Incoming data may have multiple values for <Role> tag (which has multiple values for RoleID and RoleType tag) for one nric tag

    How i should map incoming data (multiple values for Role tag) with one nric

    Need to create output xml in below format:
    eg :If two Roles(it can have any number)
    <AccessDetail>
    <PersonData>
    <NRIC>ABC</NRIC>
    <Name>Zarli</Name>
    <Status>A</Status>
    <LastLogin>192</LastLogin>
    <RolesType>
    <Role>
    <RoleID>12</RoleID>
    <RoleType>admin</RoleType>
    </Role>
    <Role>
    <RoleID>13</RoleID>
    <RoleType>mgr</RoleType>
    </Role>
    </RolesType>
    </PersonData>
    </AccessDetail>

    Thank you in advance for your help

You must be logged in to reply to this topic.