‎2009 Feb 06 6:10 PM
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
‎2009 Feb 06 6:34 PM
‎2009 Feb 09 7:41 PM
‎2009 Oct 20 6:36 PM
‎2023 May 18 8:05 AM
Here is another solution,
Hex value for string <item> is '3C6974656D3E'
and for string </item> is '3C2F6974656D3E'
with trailing new line hex value is '0A'.
Some changes in this loop
LOOP AT it_xml INTO xml_tab-d.
REPLACE ALL OCCURRENCES OF '3C6974656D3E0A' IN xml_tab-d WITH ' '.
REPLACE ALL OCCURRENCES OF '3C2F6974656D3E0A' IN xml_tab-d WITH ' '.
APPEND xml_tab.
ENDLOOP.
Hope this helps,
Thanks
Sitesh Sawant.