toXML

Function: toXML()

Converts an object or JSON string to XML.  

Syntax

toXML(input, root)

ArgumentTypeDescription
input

Object

JSON String

The object or JSON string to be converted to XML.
rootStringThe name given to the root element.

Example

toXML(getCo, "CompaniesData")

Returns the XML:

<CompaniesData><CompaniesData><CompanyID>102</CompanyID><CompanyName>Lockman, Barrows and Kessler</CompanyName><Industry>Telecoms</Industry></CompaniesData><CompaniesData><CompanyID>103</CompanyID><CompanyName>Boyle, Bogan and Mohr</CompanyName><Industry>Telecoms</Industry></CompaniesData><CompaniesData><CompanyID>104</CompanyID><CompanyName>Kassulke LLC</CompanyName><Industry>Telecoms</Industry></CompaniesData></CompaniesData>
 Pretty Printed
<CompaniesData>
    <CompaniesData>
        <CompanyID>102</CompanyID>
        <CompanyName>Lockman, Barrows and Kessler</CompanyName>
        <Industry>Telecoms</Industry>
    </CompaniesData>
    <CompaniesData>
        <CompanyID>103</CompanyID>
        <CompanyName>Boyle, Bogan and Mohr</CompanyName>
        <Industry>Telecoms</Industry>
    </CompaniesData>
    <CompaniesData>
        <CompanyID>104</CompanyID>
        <CompanyName>Kassulke LLC</CompanyName>
        <Industry>Telecoms</Industry>
    </CompaniesData>
</CompaniesData>

See Also