XML creation with incorrect tags

John

Member
Hello Team,

I am writing code to generate XML file for a table record. It is generated with some incorrect tags so I have to use replace statement to get XML in expected format.Could some provide me better solution than using replace statement? Thanks in advance.

PFA the files as follows [ I changed the .XML file extension to .txt to attach these here]:
1. a.p : This is progress 4GL code I am using.
2. Req_before.txt : This is the XML file generated with incorrect tags. [unexpected format]
3. Req.txt : This is the XML file generated after correction tags using REPLACE statement
 

Attachments

  • a.p
    1.4 KB · Views: 4
  • Req_before.txt
    402 bytes · Views: 4
  • Req.txt
    153 bytes · Views: 5

Cecil

19+ years progress programming and still learning.
Question: Does the XML Declaration (<?xml version="1.0"?>) need to be omitted?

Try this:

Code:
DEFINE TEMP-TABLE COA NO-UNDO
    NAMESPACE-URI "http://www.t.com/schemas/AC.xsd2"  NAMESPACE-PREFIX "ns0"
    FIELD AccountCode AS CHARACTER
    FIELD Description AS CHARACTER .

DEFINE DATASET COADset NAMESPACE-URI "http://www.t.com/schemas/AC.xsd2"
    XML-NODE-TYPE "HIDDEN"
    FOR COA.
  
    CREATE COA.
  
    ASSIGN
        COA.AccountCode = "2002M008"
        COA.DESCRIPTION = "Acc 1".
  
  
    DATASET COADset:WRITE-XML('file', 'file.xml', TRUE).

Output:

Code:
<?xml version="1.0"?>
<ns0:COA xmlns:ns0="http://www.t.com/schemas/AC.xsd2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ns0:AccountCode>2002M008</ns0:AccountCode>
  <ns0:Description>Acc 1</ns0:Description>
</ns0:COA>
 
Last edited:
Top