Application Development 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: 

Extracting cdata from xml file ( if_ixml_cdata_section )

Former Member
0 Kudos

Hello,

We will receive xml files containing product data that I want to upload into the sales text of our materials in JP28.

Using the iXML library with T_FILE_PARSE program as an example I can easily extract most fields but the problem is that one field has paragraphs of text in CData. Using the code bellow I can extract some of the data as a string but it's too short to get everything.

case node->get_type( ).
      when if_ixml_node=>co_node_cdata_section.
        break grainneq.

        text = node->get_value( ).
        write: / 'CDATA:'.
        write at indent text color col_group inverse.

Looking in the library

4 REPLIES 4

Former Member
0 Kudos

This is the XML file tag I'm concerned with

<longDescription><![CDATA[This chapter contains blah blah blah goes on for a few paragraphs

.......................................

.......................................

]]></longDescription>

0 Kudos

Hi,

Method GET_VALUE() returns value of type string.

text = node->get_value( ).

Please check type of text.

Regards,

Ravi.

0 Kudos

as shakar said ,

data: lt_text type table of string .

lt_text[] = node->get_value( ).

regards

Prabhu

0 Kudos

My bad, text was in fact receiving the full string (I thought it was truncating).

So I've just added a function module to split the string into lines that the CREATE_TEXT fm can handle.

Both responses were helpful so I've awarded points....although the question was probably confusing to you as the data was there along:)

Thanks for the quick response in any case.

when if_ixml_node=>co_node_cdata_section.
        
        text = node->get_value( ).

        call function 'SWA_STRING_SPLIT'
          exporting
            input_string           = text
            max_component_length   = 132
          tables
            string_components      = swastrtab.