Skip to Content
0
Former Member
Feb 06, 2009 at 06:10 PM

Remove tag <item> from XML

393 Views

Hi,

I'm creating a XML from ABAP, everything works fine but when the XML is created is added one tag <item> that i want to remove. How can i do that?

The code that i'm using is this:

CLASS cl_ixml DEFINITION LOAD.

g_ixml = cl_ixml=>create( ).

CHECK NOT g_ixml IS INITIAL.

m_document = g_ixml->create_document( ).

CHECK NOT m_document IS INITIAL.

WRITE: / 'Converting DATA TO DOM 1:'.

CALL FUNCTION 'SDIXML_DATA_TO_DOM'

EXPORTING

name = 'FICHEIROBALANCETE'

dataobject = ficheirobalancete[]

IMPORTING

data_as_dom = l_dom

CHANGING

document = m_document

EXCEPTIONS

illegal_name = 1

OTHERS = 2.

IF sy-subrc = 0.

WRITE 'Ok'.

ELSE.

WRITE: 'Err =',

sy-subrc.

ENDIF.

CHECK NOT l_dom IS INITIAL.

w_rc = m_document->append_child( new_child = l_dom ).

IF w_rc IS INITIAL.

WRITE 'Ok'.

ELSE.

WRITE: 'Err =',

w_rc.

ENDIF.

CALL FUNCTION 'SDIXML_DOM_TO_XML'

EXPORTING

document = m_document

IMPORTING

xml_as_string = w_string

size = w_size

TABLES

xml_as_table = it_xml

EXCEPTIONS

no_document = 1

OTHERS = 2.

IF sy-subrc = 0.

WRITE 'Ok'.

ELSE.

WRITE: 'Err =',

sy-subrc.

ENDIF.

LOOP AT it_xml INTO xml_tab-d.

APPEND xml_tab.

ENDLOOP.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

bin_filesize = w_size

filename = nome_fich

filetype = 'BIN'

TABLES

data_tab = xml_tab

EXCEPTIONS

OTHERS = 10.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

Best regards,

Ricardo