我是4gl的新秀。谁能说出如何使用Progress 4GL中的SAX-WRITER导出XML格式,如下所示。这是格式;
<?xml version="1.0" encoding="UTF-8"?>
<IoTInfo>
<Info Name="ApplicationID" Value="IoTBuffer" />
<Info Name="ResourceID" Value="Lansing_DO" />
<Info Name="HostName" Value="Adient-RTA-USE-IoTHub-01.azure-devices.net" />
<Info Name="DeviceId" Value="582-01" />
<Info Name="PrimaryDeviceKey" Value="4n3yEihan+ikfEe1EkI0i/CNeTfiMHdzQCcUQthO4R4=" />
<Info Name="SecondaryDeviceKey" Value="Ue7dNJvVYGRmyVIl4l91hQS0TUDCwvdLs/2X+OWUBe0=" />
<Info Name="TransportType" Value="Mqtt_WebSocket_Only" />
<Info Name="RetryPolicy" Value="Exponential_Backoff_With_Jitter" />
<Info Name="OperationTimeout" Value="15000" />
<Info Name="IoTMessage" Value="{"DeviceId":"469"}" />
<Info Name="MsgTimeStamp" Value="11/20/2019 1:40:12 PM" />
</IoTInfo>
最佳答案
您不需要为此使用SAX-WRITER。您可以定义一个简单的数据集和一个临时表,并输出它的XML表示形式。
DEFINE TEMP-TABLE ttInfo NO-UNDO SERIALIZE-NAME "info"
FIELD InfoName AS CHARACTER XML-NODE-TYPE "attribute" SERIALIZE-NAME "Name"
FIELD InfoValue AS CHARACTER XML-NODE-TYPE "attribute" SERIALIZE-NAME "Value" .
DEFINE DATASET dsInfo SERIALIZE-NAME "IoTInfo" FOR ttInfo .
CREATE ttInfo.
ASSIGN ttInfo.InfoName = "ApplicationID"
ttInfo.InfoValue = "InfoValue".
CREATE ttInfo.
ASSIGN ttInfo.InfoName = "ResourceID"
ttInfo.InfoValue = "Lansing_DO".
DATASET dsInfo:WRITE-XML("file", "c:\temp\xml.xml", FALSE).
DISPLAY "Done".