Αναζήτηση

Thursday, June 21, 2012

Read utf-8 xml file with abap

Read utf-8 xml file and store it in string variable :
--------------------------------------------------------------
www.developerpages.gr
*
* Read UTF-8 xml file
*
*--------------------------------------------------------------
report zread_xml.

data XML_STRING type STRING.
DATA line TYPE string.


clear xml_string.
PARAMETERS xml_file(255).

OPEN DATASET xml_file IN TEXT MODE for input ENCODING UTF-8 .
if sy-subrc = 0.
  DO.
    READ DATASET xml_file INTO line.
    IF sy-subrc <> 0.
      EXIT.
    else.
      CONCATENATE xml_string line INTO xml_string.
    ENDIF.
  ENDDO.
  if not xml_string is initial.
    write :/ 'ready to parse xml...'.
  else.
    write :/ 'file is empty ! ', xml_file.
  endif.
else.
  WRITE :/ 'cannot open file ', xml_file.
endif.

Original article : http://developerpages.gr/index.php/el/desktop-development-2/abap/71-read-utf-8-xml-file-with-abap

No comments:

Post a Comment