<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to replace the XML root tag in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012941#M958818</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got it.&lt;/P&gt;&lt;P&gt;Just need to create the root element and set the attributes using the set_attribute method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;w_element_inv1  = w_document-&amp;gt;create_simple_element(
                  name = 'OrbiscomRequest'
                  parent = w_document ).

      w_element_inv1-&amp;gt;set_attribute( name = 'Version'
                                     namespace = ''
                                     value = '11.1' ).

      w_element_inv1-&amp;gt;set_attribute( name = 'IssuerID'
                                     namespace = ''
                                     value = '1' ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Sep 2011 19:41:29 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-09-20T19:41:29Z</dc:date>
    <item>
      <title>How to replace the XML root tag</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012939#M958816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;how to replace the root tag with the certain string in ABAP Mapping&lt;/P&gt;&lt;P&gt;just like&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;root&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;header&amp;gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;lt;name&amp;gt;Lawrence&amp;lt;/name&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;/header&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;Body&amp;gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;lt;value&amp;gt;test&amp;lt;/value&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;Body&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/root&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;into&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;myRoot&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;header&amp;gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;lt;name&amp;gt;Lawrence&amp;lt;/name&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;/header&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;Body&amp;gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;lt;value&amp;gt;test&amp;lt;/value&amp;gt;&lt;/P&gt;&lt;P&gt;---&amp;lt;Body&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/myRoot&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the following is my abap code:&lt;/P&gt;&lt;P&gt;method IF_MAPPING~EXECUTE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;initialize iXML&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;type-pools: ixml.&lt;/P&gt;&lt;P&gt;class cl_ixml definition load.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;create main factory&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: ixmlfactory type ref to if_ixml.&lt;/P&gt;&lt;P&gt;ixmlfactory = cl_ixml=&amp;gt;create( ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;create stream factory&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: streamfactory type ref to if_ixml_stream_factory.&lt;/P&gt;&lt;P&gt;streamfactory = ixmlfactory-&amp;gt;create_stream_factory( ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;create input stream&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: istream type ref to if_ixml_istream.&lt;/P&gt;&lt;P&gt;istream = streamfactory-&amp;gt;create_istream_xstring( source ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;parse input document =================================================&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;initialize input document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: idocument type ref to if_ixml_document.&lt;/P&gt;&lt;P&gt;idocument = ixmlfactory-&amp;gt;create_document( ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;parse input document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: iparser type ref to if_ixml_parser.&lt;/P&gt;&lt;P&gt;iparser = ixmlfactory-&amp;gt;create_parser( stream_factory = streamfactory&lt;/P&gt;&lt;P&gt;istream = istream&lt;/P&gt;&lt;P&gt;document = idocument ).&lt;/P&gt;&lt;P&gt;iparser-&amp;gt;parse( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get message content of tag root element&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: l_root type ref to if_ixml_element.&lt;/P&gt;&lt;P&gt;l_root = idocument-&amp;gt;get_root_element( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: l_children type ref to IF_IXML_NODE_LIST.&lt;/P&gt;&lt;P&gt;l_children = l_root-&amp;gt;GET_CHILDREN( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;build up output document =============================================&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;create output document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;data: odocument type ref to if_ixml_document.&lt;/P&gt;&lt;P&gt;odocument = ixmlfactory-&amp;gt;create_document( ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;create the root element&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: root type ref to if_ixml_node.&lt;/P&gt;&lt;P&gt;root = odocument-&amp;gt;create_element( name = 'myRoot' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*append the children to the new tag&lt;/P&gt;&lt;P&gt;data: l_index type i.&lt;/P&gt;&lt;P&gt;data: l_length type i.&lt;/P&gt;&lt;P&gt;data irc type i.&lt;/P&gt;&lt;P&gt;data: temp_node type ref to IF_IXML_NODE.&lt;/P&gt;&lt;P&gt;l_length = l_children-&amp;gt;get_length( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while ( l_index &amp;lt; l_length ).&lt;/P&gt;&lt;P&gt;temp_node = l_children-&amp;gt;get_item( l_index ).&lt;/P&gt;&lt;P&gt;irc = root-&amp;gt;append_child( temp_node ).&lt;/P&gt;&lt;P&gt; l_index = l_index + 1.&lt;/P&gt;&lt;P&gt;endwhile.&lt;/P&gt;&lt;P&gt;odocument-&amp;gt;append_child( root ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: ostream type ref to if_ixml_ostream.&lt;/P&gt;&lt;P&gt;ostream = streamfactory-&amp;gt;create_ostream_xstring( result ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;create renderer&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data: renderer type ref to if_ixml_renderer.&lt;/P&gt;&lt;P&gt;renderer = ixmlfactory-&amp;gt;create_renderer( ostream = ostream&lt;/P&gt;&lt;P&gt;document = odocument ).&lt;/P&gt;&lt;P&gt;irc = renderer-&amp;gt;render( ).&lt;/P&gt;&lt;P&gt;endmethod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i only got header in my xml without Body element&lt;/P&gt;&lt;P&gt;help me please&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jun 2008 06:57:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012939#M958816</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-20T06:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the XML root tag</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012940#M958817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lawrence,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;did you got the solution? I am also having the same kind of requirement and to add two attributes to the root element.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding ="UTF-8"?&amp;gt;
&amp;lt;Response IssuerID="1" Version="11.3"&amp;gt;
  -Child elemetn
  -Child element2
  -.......
  ........
&amp;lt;/Response&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here Response is the root element and the attributes are IssuerID and Version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please suggest how can we get this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ranganadh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2011 17:25:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012940#M958817</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-20T17:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the XML root tag</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012941#M958818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got it.&lt;/P&gt;&lt;P&gt;Just need to create the root element and set the attributes using the set_attribute method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;w_element_inv1  = w_document-&amp;gt;create_simple_element(
                  name = 'OrbiscomRequest'
                  parent = w_document ).

      w_element_inv1-&amp;gt;set_attribute( name = 'Version'
                                     namespace = ''
                                     value = '11.1' ).

      w_element_inv1-&amp;gt;set_attribute( name = 'IssuerID'
                                     namespace = ''
                                     value = '1' ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2011 19:41:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012941#M958818</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-20T19:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the XML root tag</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012942#M958819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To do that, the following can be done&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lif_ixml_document is the factory&lt;/P&gt;&lt;P&gt;lif_ixml_elementn is the new root&lt;/P&gt;&lt;P&gt;lif_ixml_elemento is the old root&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lif_ixml_elemento = lif_ixml_document-&amp;gt;get_root_element( ).&lt;/P&gt;&lt;P&gt;lif_ixml_elementn = lif_ixml_document-&amp;gt;create_simple_element_ns( name = 'myroot' parent = lif_ixml_document ).&lt;/P&gt;&lt;P&gt;lif_ixml_elementn-&amp;gt;if_ixml_node~append_child( lif_ixml_elemento ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jun 2012 22:12:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-replace-the-xml-root-tag/m-p/4012942#M958819</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-29T22:12:14Z</dc:date>
    </item>
  </channel>
</rss>

