Parsing XML file with long strings on 9.1B

Potish

Member
I setup a simple progress program to parse XML files and it works well for most of the files. There are however some files that have fairly long strings of data in one of the nodes and I get an error when I try to assign the value from that node to a character variable. I am working with Progress 9.1B so I do not have access to the LONGCHAR data type. Is there a workaround to this limit that I can use for now as upgrading it not very feasible. A simplified version of the section of code where the error occurs looks as follows

DO i = 1 TO gh001:NUM-CHILDREN:
gh001:GET-CHILD(gh002,i).

IF gh002:NAME = "body" THEN
DO:
gh002:GET-CHILD(ghtext,1).
vcparagraph = TRIM(vcparagraph) + TRIM(ghtext:NODE-VALUE).
END.
END

The error I get is "x-noderef or x-document NODE-VALUE got an error: string length too long. (9083)"
 
I think you will need to use the NODE-VALUE-TO-MEMPTR() method and then grab the bits out of the memptr that you can handle.
 
Code:
IF my-xnoderef:SUBTYPE = "#TEXT" THEN DO: 
  IF LENGTH(my-xnoderef:NODE-VALUE, "RAW") > 32000 THEN DO: 
    ASSIGN 
      succes = my-xnoderef:[B]NODE-VALUE-TO-MEMPTR(my-memptr) 
      pos    = 1 
      len    = 32000. 
    DO WHILE pos < GET-SIZE(my-memptr): 
      my-nodeval = GET-STRING(my-memptr, pos, len). 
      [B]/* Do something with my-nodeval */ 
      pos = pos + len. 
    END. 
    SET-SIZE(my-memptr) = 0. 
  END. 
  ELSE 
    my-nodeval = my-xnoderef:NODE-VALUE. 
END.
[/B][/B]
 
Thank you for the suggestion to use NODE-VALUE-TO-MEMPTR() method. I do my development using 9.1B and NODE-VALUE-TO-MEMPTR() was not available on that version. However I also run 9.1E on the production region so I am hoping I can get it working there.
 
The mind boggles why someone would do maintenance in 9.1B when production was 9.1E .... unless someone hadn't paid their maintenance.
 
Back
Top