Progress 4GL: Reading from XML to Dataset

Status
Not open for further replies.
U

user3790173

Guest
When I'm trying to read from XML to TempTables using the Dataset and READ-XML method it works okay. But the problem is so: If there is attribute in tag then it returns empty result instead of element value. Tried it in different ways, but didn't get any results.

I found that it works only if the attribute name is "xmlns" like in this case Reading XML file to Dataset in Progress-4gl.

Here is my code and XML.

<?xml version="1.0" encoding="ISO-8859-15"?>
<?xml-stylesheet type="text/xsl" href="Test.xsl"?>
<ReceiverInfo Version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Test.xsd">
<MessageDetails>
<MessageTypeCode Axmlns="">RECEIVERINFO</MessageTypeCode>
</MessageDetails>
<MessageDetails>
<MessageTypeCode Axmlns="">RECEIVERINFO2</MessageTypeCode>
</MessageDetails>
</ReceiverInfo>


And code:

def var icount as int no-undo initial 0.

DEF TEMP-TABLE ReceiverInfo NO-UNDO
FIELD foo AS LOG.

DEF TEMP-TABLE MessageDetails NO-UNDO
FIELD MessageTypeCode as CHAR XML-NODE-TYPE "Element".

DEF DATASET data FOR ReceiverInfo, MessageDetails.

DATASET data:READ-XML("file", "/home/ars/temp/tofile.xml", "empty", ?, FALSE, ?, "IGNORE") NO-ERROR.

DO icount = 1 TO ERROR-STATUS:NUM-MESSAGES:
DISP ERROR-STATUS:GET-MESSAGE(icount) format "x(50)".
END.

FOR EACH MessageDetails.
DISP MessageDetails.MessageTypeCode format "x(40)".
END.


Thanks for help!

Continue reading...
 
Status
Not open for further replies.
Top