Updated on 2023-02-28 GMT+08:00

XmlUtils

Path

com.roma.apic.livedata.common.v1.XmlUtils

Description

This class is used to provide the XML conversion function.

Example

1
2
3
4
5
importClass(com.roma.apic.livedata.common.v1.XmlUtils);
function execute(data) {
    var xml = '<a><id>2</id><name>1</name></a>'
    return XmlUtils.toMap(xml)
}

Method List

Returned Type

Method and Description

static String

toJson(String xml)

Convert a character string in the XML format into a JSON file.

static Map<String,Object>

toMap(String xml)

Convert XML into Map.

static String

toXml(Object object)

Convert an object into an XML file.

static String

toXml(Object object, Map<String,Object> config)

Convert an object into an XML file.

Method Details

  • public static String toJson(String xml)

    Convert a character string in the XML format into a JSON file.

    Input Parameter

    xml indicates the character string in XML format.

    Returns

    Character string in JSON format.

    Throws

    org.json.JSONException

  • public static Map<String,Object> toMap(String xml)

    Convert XML into Map.

    Input Parameter

    xml indicates the character string in XML format.

    Returns

    Character string in MAP format.

  • public static String toXml(Object object)

    Convert an object into an XML file.

    Input Parameter

    object indicates the object to be converted.

    Returns

    Character string in XML format.

    Throws

    java.lang.Exception

  • public static String toXml(Object object, Map<String,Object> config)

    Convert an object into XML.

    Input Parameter

    • object indicates the object to be converted.
    • config indicates the conversion configuration.

    Returns

    Character string in XML format.

    Throws

    java.lang.Exception