Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Converting XML string to internal table

Former Member
0 Likes
1,297

Hello everyone,

I am trying to convert an XML string to an internal table. The format of the XML string is as follows:

<node label="Compressors" NODE_ID="783" checked="1" expandStatus="false">

<node label="Nail guns" NODE_ID="78543" checked="1" expandStatus="false"/>

<node label="Spray guns" NODE_ID="855" checked="0" expandStatus="false"/>

<node label="Cleaning equipment" NODE_ID="9" checked="1" expandStatus="false"/>

</node>

What I need is an internal table with the fields NODE_ID and checked filled. The hierarchy here doesn't matter, so I just need an internal table of a structure with 2 fields. The whole XML is hierarchical and contains only the <node> tag, which can be self-closing or not with the attributes within the tag.

What is the best way to accomplish this?

Performance here is quite important too, as this XML can contain over 100,000 nodes.

Should it be done with an xpath expression, with a regex, with the iXML parser, an XSLT call transformation?

Any help is greatly appreciated!

Best regards,

Vincent

2 REPLIES 2
Read only

Former Member
0 Likes
516

Hi,

did you manage to get this to work?

I have the same thing here that I have to do.

thanks,

Caroline,

Read only

NAeda
Contributor
0 Likes
516

Use this FM to get into internal table

            CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
              EXPORTING
                im_xstring = zl_attcntx
              IMPORTING
                ex_string  = zl_attcont.

   SPLIT zl_attcont AT cl_abap_char_utilities=>newline INTO TABLE zit_legacy.