<?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 Transform XML-String to human readable XML-File in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705938#M626927</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to transform a XML-String as coming from a simple transformation into a human readable XML-File. That means with linebreaks and logical indenting, each line not longer than n charactors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;one&amp;gt;&amp;lt;two&amp;gt;text&amp;lt;/two&amp;gt;&amp;lt;three&amp;gt;&amp;lt;four&amp;gt;text&amp;lt;/four&amp;gt;&amp;lt;/three&amp;gt;&amp;lt;/one&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;into &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;one&amp;gt;
  &amp;lt;two&amp;gt;text&amp;lt;/two&amp;gt;
  &amp;lt;three&amp;gt;
    &amp;lt;four&amp;gt;text&amp;lt;/four&amp;gt;
  &amp;lt;/three&amp;gt;
&amp;lt;/one&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Aug 2007 08:06:29 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-21T08:06:29Z</dc:date>
    <item>
      <title>Transform XML-String to human readable XML-File</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705938#M626927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to transform a XML-String as coming from a simple transformation into a human readable XML-File. That means with linebreaks and logical indenting, each line not longer than n charactors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;one&amp;gt;&amp;lt;two&amp;gt;text&amp;lt;/two&amp;gt;&amp;lt;three&amp;gt;&amp;lt;four&amp;gt;text&amp;lt;/four&amp;gt;&amp;lt;/three&amp;gt;&amp;lt;/one&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;into &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;one&amp;gt;
  &amp;lt;two&amp;gt;text&amp;lt;/two&amp;gt;
  &amp;lt;three&amp;gt;
    &amp;lt;four&amp;gt;text&amp;lt;/four&amp;gt;
  &amp;lt;/three&amp;gt;
&amp;lt;/one&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2007 08:06:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705938#M626927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-21T08:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Transform XML-String to human readable XML-File</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705939#M626928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah I need to do the same.  The "RENDER_2_STRING" method of CL_XML_DOCUMENT_BASE has a parameter for pretty printing but it doesn't appear to work - i.e. it doesn't insert CR/LF into the XML string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you manage to figure this one out (and vice-versa I'll let you know if I figure it out).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2007 11:36:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705939#M626928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-16T11:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Transform XML-String to human readable XML-File</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705940#M626929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wrote a method that will do this, but the method can not handle all kinds of XML-strings, but it works with most simple XML-Strings:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD xml_str2table.
*** Importing
**    I_XMLSTRING type csequence
*** Returning
***   e_tab_XMLtab type table of string.         

  DATA l_cnt_length TYPE i.
  l_cnt_length = STRLEN( i_xmlstring ).
  DATA l_cnt_index TYPE i.
  DATA l_xmlline TYPE string.
  DATA l_oldchar TYPE c.
  DATA l_char TYPE c.
  DATA l_nextchar TYPE c.
  DATA l_indent TYPE i.
  DO l_cnt_length TIMES.
    l_cnt_index = sy-index - 1.
    l_char = i_xmlstring+l_cnt_index(1).
    IF sy-index &amp;lt; l_cnt_length.
      l_nextchar = i_xmlstring+sy-index(1).
    ENDIF.
    IF  l_char &amp;lt;&amp;gt; cl_abap_char_utilities=&amp;gt;newline.

      IF ( l_char = '&amp;lt;' AND l_nextchar = '/' ) OR
         ( l_char = '/' AND l_nextchar = '&amp;gt;' ).
        l_indent = l_indent - 1.
        IF l_indent &amp;lt; 0.
          l_indent = 0.
        ENDIF.
      ENDIF.

      IF l_char = '&amp;lt;' AND l_oldchar = '&amp;gt;'.
        APPEND l_xmlline TO e_tab_xmltab.
*      write: / l_xmlline.
        CLEAR l_xmlline.
        DO l_indent TIMES.
          CONCATENATE space space l_xmlline INTO l_xmlline SEPARATED BY space.
        ENDDO.
      ENDIF.
      if l_char &amp;lt;&amp;gt; space.
        CONCATENATE l_xmlline l_char INTO l_xmlline.
      else.
        CONCATENATE l_xmlline l_char INTO l_xmlline SEPARATED BY space.
      endif.

      IF l_char = '&amp;lt;' AND l_nextchar &amp;lt;&amp;gt; '/'.
        l_indent = l_indent + 1.
      ENDIF.

    ELSE.
      l_indent = 0.
      APPEND l_xmlline TO e_tab_xmltab.
*    write: / l_xmlline.
      CLEAR l_xmlline.
    ENDIF.
    l_oldchar = l_char.
  ENDDO.
  APPEND l_xmlline TO e_tab_xmltab.
*write: / l_xmlline.

ENDMETHOD. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The second Method does the same not with an string, but with an X-String:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;



METHOD xml_xstr2table.
*** Importing
**    I_XMLSTRING type xsequence
*** Returning
***   e_tab_XMLtab type table of string.      

  DATA l_tmp_string TYPE string.

  DATA conv TYPE REF TO cl_abap_conv_in_ce.
  conv = cl_abap_conv_in_ce=&amp;gt;create(
            encoding = 'UTF-8'
            endian = 'L' ).
  conv-&amp;gt;convert(
    EXPORTING input = i_xmlstring
    IMPORTING data = l_tmp_string ).

  e_tab_xmltab = xml_str2table( l_tmp_string ).

ENDMETHOD. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2007 12:37:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705940#M626929</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-16T12:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Transform XML-String to human readable XML-File</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705941#M626930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great!  Thanks Achim!  Much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2007 13:35:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705941#M626930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-16T13:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Transform XML-String to human readable XML-File</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705942#M626931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem consists in the class CL_XML_DOCUMENT_BASE RENDER method in which the method call is inserted &lt;/P&gt;&lt;P&gt;l_renderer-&amp;amp;gt; set_normalizing (is_normalizing = space).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It brings that all text in one line.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial, Helvetica, sans-serif; background-color: #cbdbea;"&gt; &lt;/SPAN&gt;&lt;A class="urLnkFunction urVt1 active_link" href="https://service.sap.com/sap/support/notes/577559" style="color: #204ba2; text-decoration: underline; font-family: Arial, Helvetica, sans-serif; background-color: #cbdbea;" title="Right mouse click to add this SAP Note to your browser favorites"&gt;&lt;SPAN class="urTxtH1" id="header_data" style="font-weight: bold;"&gt;Note 577559 - Leading blanks in XML documents&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="urTxtH1" style="font-weight: bold;"&gt;The decision in a forehead to generate a class the successor from the class cl_xml_document and to redefine the render method&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Sep 2013 06:46:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705942#M626931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-27T06:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Transform XML-String to human readable XML-File</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705943#M626932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much for finding this!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It sees that normalization needs to be TRUE for pretty printing to work... huh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So much better to use text (faster) than relying on IE's slow XML rendering.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2016 17:54:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-xml-string-to-human-readable-xml-file/m-p/2705943#M626932</guid>
      <dc:creator>marius_piedalluvanwyk2</dc:creator>
      <dc:date>2016-08-15T17:54:37Z</dc:date>
    </item>
  </channel>
</rss>

