‎2007 Sep 28 12:34 PM
Hi,
Can anyone send XML parsing code in Abap?
Thanks & Regards,
Jeba.
‎2007 Sep 28 1:23 PM
‎2007 Sep 28 1:39 PM
hi
good
go through this code
form parse_xml_document.
data: lo_parse_error type ref to if_ixml_parse_error.
clear: gf_onoff.
*-- Create the main factory
go_ixml = cl_ixml=>create( ).
*-- Create the initial document
go_xmldoc = go_ixml->create_document( ).
*-- Create the stream factory
go_stream_factory = go_ixml->create_stream_factory( ).
*-- Create an input stream for the table
go_istream = go_stream_factory->create_istream_itable(
table = gt_xml_table
size = g_filesize ).
*-- Create the parser
go_xmlparser = go_ixml->create_parser(
stream_factory = go_stream_factory
istream = go_istream
document = go_xmldoc ).
*-- Parse the stream
if go_xmlparser->parse( ) is initial.
go_xmlnode = go_xmldoc.
perform build_xml_tag_fields.
else.
gf_onoff = c_on.
if go_xmlparser->num_errors( ) ne 0.
g_cntmain = go_xmlparser->num_errors( ).
format color col_negative.
write: / g_cntmain, ' parse errors have occurred'.
skip 2.
clear g_cntloop.
while g_cntloop < g_cntmain.
lo_parse_error = go_xmlparser->get_error( index = g_cntloop ).
g_cntsub = lo_parse_error->get_line( ).
write: / 'Line: ', (3) g_cntsub.
g_cntsub = lo_parse_error->get_column( ).
write: 'Column: ', (3) g_cntsub.
g_tmpstr = lo_parse_error->get_reason( ).
write: g_tmpstr no-gap.
g_cntloop = g_cntloop + 1.
endwhile.
endif.
endif.
clear: g_cntmain, g_cntsub.
endform. " parse_xml_document
thanks
mrutyun^