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: 

how to remove ?xml version="1.0"?

former_member498821
Participant
0 Kudos

hi ,

i create one spacific format xml using i xml but the format spacification i don't want this tag is '?xml version="1.0"?

my sample code is ::

<?xml version="1.0" ?> ) i want tot trmove )

- <ENVELOPE>

- <HEADER>

<TALLYREQUEST>Import data</TALLYREQUEST>

</HEADER>

- <BODY>

- <IMPORTDATA>

- <REQUESTDESC>

<REPORTNAME>Vouchers</REPORTNAME>

- <STATICVARIABLES>

regards

venkat

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

I know you can do it with the transformations, but I don't know with iXML.

So you could at least "transform" the xml stream that is output by iXML:


CALL TRANSFORMATION id
      SOURCE XML l_string
      RESULT XML l_string
      OPTIONS xml_header = 'no'.

As it probably has a significant memory/performance cost, you may also use this simple replacement:


REPLACE REGEX '^<\?xml.*\?>' IN l_string WITH ``.

Madhurivs23
Participant
0 Kudos

Hello Venkat,

How did you solve this issue? I am also generating XML file using ixml interface. and I want to remove the header part : <?xml version="1.0" >

Thanks and regards,

MadhuriS

0 Kudos

Hi Sandra,

Thanks! your solution works.

I did through following way

call transformation id

               source xml L_XML_TABLE

               result XML L_STRING

               options

               xml_header = 'no'.

         call transformation id

               source xml L_STRING

               result XML L_XML_TABLE.

And it works.

It saved my lot of time of doing it again using simple transformations.

Hope I could have assign full marks to your solution

Regards,

Madhuri

0 Kudos

With IXML, you may use "document->set_declaration( abap_false )" to not render the XML header:

ixml = cl_ixml=>create( ).
document = ixml->create_document( ).
element = document->create_simple_element( name   = 'ROOT'
                                           parent = document ).
stream_factory = ixml->create_stream_factory( ).
ostream = stream_factory->create_ostream_xstring( xstring ).
renderer = ixml->create_renderer( ostream  = ostream
                                  document = document ).
document->set_declaration( abap_false ).
rc = renderer->render( ).
cl_abap_unit_assert=>assert_equals( act = cl_abap_codepage=>convert_from( xstring )
                                    exp = '<ROOT/>' ).