<?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: ABAP mapping  XML inside another XML in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-mapping-xml-inside-another-xml/m-p/2695554#M623837</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in the input xml CDATA section is not properly formed, hope this is typo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there is an extra &amp;gt; sign in the xml with CDATA section , remove it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&amp;gt;&amp;lt;?xml version="1.0"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the first &amp;gt; sign should be removed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Aug 2007 09:39:12 GMT</pubDate>
    <dc:creator>athavanraja</dc:creator>
    <dc:date>2007-08-27T09:39:12Z</dc:date>
    <item>
      <title>ABAP mapping  XML inside another XML</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-mapping-xml-inside-another-xml/m-p/2695553#M623836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From XI we want to make an abap mapping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The input xml looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ns0:mt_dummy xmlns:ns0="http://kmd.dk/phh/externalEventEngine/pfhaen"&amp;gt;&lt;/P&gt;&lt;P&gt;   &amp;lt;details&amp;gt;&lt;/P&gt;&lt;P&gt;        &amp;lt;Navn&amp;gt;Nielsen&amp;lt;/Navn&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;Adresse&amp;gt;&amp;lt;![CDATA[&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;lt;ns0:mt_dummy2 xmlns:ns0="http://kmd.dk/phh/externalEventEngine/pfhaen"&amp;gt;&amp;lt;Details2&amp;gt;&amp;lt;Vej&amp;gt;tingvej&amp;lt;/Vej&amp;gt;&amp;lt;Husnr&amp;gt;75&amp;lt;/Husnr&amp;gt;&amp;lt;/Details2&amp;gt;&amp;lt;/ns0:mt_dummy2&amp;gt;]]&amp;gt;&amp;lt;/Adresse&amp;gt;&lt;/P&gt;&lt;P&gt;   &amp;lt;/details&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/ns0:mt_dummy&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; One of the fields in this structure &amp;lt;Adresse&amp;gt; contains another xml structure. It is this structure we want as a result of our ABAP mapping. First we get the value of the field &amp;lt;Adresse&amp;gt;. This field contains the actual xml structure that we want to map. We convert the structure to xstring and run it through a new parser and create our output document.(See code below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code works fine if we just use a &amp;#145;normal&amp;#146; xml structure, but when one of the fields contains a XML structure and we want to parse this structure, we get the error. Is there anything we have missed, or is this not possible in ABAP mapping ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If we test the code with SXI_MAPPING_TEST we get no errors, but in runtime we get the following error in SXMB_MONI:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#145;The XML page document can not be shown&lt;/P&gt;&lt;P&gt;The XML document must have an element at the top level&amp;#146;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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 xml&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;P&gt;&lt;/P&gt;&lt;P&gt;*create main factory&lt;/P&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;P&gt;&lt;/P&gt;&lt;P&gt;*create stream factory&lt;/P&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;P&gt;&lt;/P&gt;&lt;P&gt;*create input stream&lt;/P&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;P&gt;&lt;/P&gt;&lt;P&gt;*initialize input document&lt;/P&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;P&gt;&lt;/P&gt;&lt;P&gt;*parse input document&lt;/P&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;&lt;/P&gt;&lt;P&gt;  iparser-&amp;gt;parse( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: pnode type ref to if_ixml_node,&lt;/P&gt;&lt;P&gt;        pnode2 type ref to if_ixml_node,&lt;/P&gt;&lt;P&gt;        pnode3 type ref to if_ixml_node.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data: l_blob type string,&lt;/P&gt;&lt;P&gt;        l_xml type string,&lt;/P&gt;&lt;P&gt;        l_length type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  pnode = idocument.&lt;/P&gt;&lt;P&gt;  pnode2 = pnode-&amp;gt;get_first_child( ).&lt;/P&gt;&lt;P&gt;  pnode2 = pnode2-&amp;gt;get_first_child( ).&lt;/P&gt;&lt;P&gt;  pnode2 = pnode2-&amp;gt;get_last_child( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  l_blob = pnode2-&amp;gt;get_value( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: l_blob2 type xstring.&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      TEXT           = l_blob&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  MIMETYPE       = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  ENCODING       =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   IMPORTING&lt;/P&gt;&lt;P&gt;     BUFFER         = l_blob2&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  FAILED         = 1&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  OTHERS         = 2&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;            .&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*2. parse&lt;/P&gt;&lt;P&gt;*create main factory&lt;/P&gt;&lt;P&gt;  data: ixmlfactory2 type ref to if_ixml.&lt;/P&gt;&lt;P&gt;  ixmlfactory2 = cl_ixml=&amp;gt;create( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*create stream factory&lt;/P&gt;&lt;P&gt;  data: streamfactory2 type ref to if_ixml_stream_factory.&lt;/P&gt;&lt;P&gt;  streamfactory2 = ixmlfactory2-&amp;gt;create_stream_factory( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*create input stream&lt;/P&gt;&lt;P&gt;  data: istream2 type ref to if_ixml_istream.&lt;/P&gt;&lt;P&gt;  istream2 = streamfactory2-&amp;gt;create_istream_xstring( l_blob2 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*initialize input document&lt;/P&gt;&lt;P&gt;  data: idocument2 type ref to if_ixml_document.&lt;/P&gt;&lt;P&gt;  idocument2 = ixmlfactory2-&amp;gt;create_document( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*parse input document&lt;/P&gt;&lt;P&gt;  data: iparser2 type ref to if_ixml_parser.&lt;/P&gt;&lt;P&gt;  iparser2 = ixmlfactory2-&amp;gt;create_parser( stream_factory = streamfactory2&lt;/P&gt;&lt;P&gt;                                        istream        = istream2&lt;/P&gt;&lt;P&gt;                                        document       = idocument2 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  iparser2-&amp;gt;parse( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data: odocument type ref to if_ixml_document.&lt;/P&gt;&lt;P&gt;  odocument = idocument2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data: irc type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*render document----&lt;/P&gt;&lt;HR originaltext="------------------------------" /&gt;&lt;P&gt;*create output stream&lt;/P&gt;&lt;P&gt;  data: ostream type ref to if_ixml_ostream.&lt;/P&gt;&lt;P&gt;  ostream = streamfactory2-&amp;gt;create_ostream_xstring( result ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*create renderer&lt;/P&gt;&lt;P&gt;  data: renderer type ref to if_ixml_renderer.&lt;/P&gt;&lt;P&gt;  renderer = ixmlfactory2-&amp;gt;create_renderer( ostream = ostream&lt;/P&gt;&lt;P&gt;                                           document = odocument ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  irc = renderer-&amp;gt;render( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmethod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Aug 2007 11:22:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-mapping-xml-inside-another-xml/m-p/2695553#M623836</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-22T11:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP mapping  XML inside another XML</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-mapping-xml-inside-another-xml/m-p/2695554#M623837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in the input xml CDATA section is not properly formed, hope this is typo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there is an extra &amp;gt; sign in the xml with CDATA section , remove it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&amp;gt;&amp;lt;?xml version="1.0"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the first &amp;gt; sign should be removed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 09:39:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-mapping-xml-inside-another-xml/m-p/2695554#M623837</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2007-08-27T09:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP mapping  XML inside another XML</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-mapping-xml-inside-another-xml/m-p/2695555#M623838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem solved. &lt;/P&gt;&lt;P&gt;The 'error' was in the 'SXI_MAPPING_TEST' transaction. In here the 'CDATA' code was removed automatically and the result was a success, but when we debugged in runtime, the CDATA characters was not removed. When we moved the data with: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;replace first occurrence of '&amp;lt;![CDATA[' in l_blob with '' .
replace first occurrence of '' in l_blob with ''.]]&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;everything was fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 10:50:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-mapping-xml-inside-another-xml/m-p/2695555#M623838</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-27T10:50:06Z</dc:date>
    </item>
  </channel>
</rss>

