<?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: Read XML from a String in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-xml-from-a-string/m-p/5797402#M1311087</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to create a XSLT Transformation and call that by passing your XML string and get the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lf_string TYPE string.
DATA: xml_string TYPE string.

lf_string = 'This single variable test'.

TRY.

* This call gets me the XML data. You need to skip this as you 
* already have the XML string
    CALL TRANSFORMATION ztest_np_xml2data
      SOURCE if_test = lf_string
      RESULT XML xml_string.

    CLEAR lf_string.

    CALL TRANSFORMATION ztest_np_xml2data
      SOURCE XML xml_string
      RESULT if_test = lf_string.

  CATCH cx_st_error.

ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Transformation ZTEST_NP_XML2DATA &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform template="temp"
    xmlns:tt="http://www.sap.com/transformation-templates"
    version="0.1"&amp;gt;

  &amp;lt;tt:root name="IF_TEST"/&amp;gt;

  &amp;lt;tt:template name="temp"&amp;gt;
    &amp;lt;Test&amp;gt;
        &amp;lt;tt:value ref="IF_TEST" /&amp;gt;
    &amp;lt;/Test&amp;gt;
  &amp;lt;/tt:template&amp;gt;

&amp;lt;/tt:transform&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this example from Help: &lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/a4/1f1e400191f72ee10000000a1550b0/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/a4/1f1e400191f72ee10000000a1550b0/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Jun 2009 16:53:09 GMT</pubDate>
    <dc:creator>naimesh_patel</dc:creator>
    <dc:date>2009-06-17T16:53:09Z</dc:date>
    <item>
      <title>Read XML from a String</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-xml-from-a-string/m-p/5797401#M1311086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have called a Web Service that return an XML Sting. This is the abap code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

REPORT  zprova_proxy line-SIZE 1000.

DATA: proxy TYPE REF TO zco_service1soap.
DATA: intab  TYPE zget_dati_vestiariosoap_in.
DATA: output TYPE zget_dati_vestiariosoap_out.
DATA : sys_fault TYPE REF TO cx_ai_system_fault.


CREATE OBJECT proxy
  EXPORTING
    logical_port_name = 'PORTA'.
IF sy-subrc EQ 0.
  TRY.
      CALL METHOD proxy-&amp;gt;get_dati_vestiario
        EXPORTING
          input  = intab
        IMPORTING
          output = output.
    CATCH cx_ai_system_fault .
      CREATE OBJECT sys_fault.
      WRITE :/ 'error at level 1', sys_fault-&amp;gt;errortext.
      EXIT.
    CATCH cx_ai_application_fault .
  ENDTRY.



ENDIF.


WRITE /: output-get_dati_vestiarioresult.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I write the output field I have an XML String.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to access XML tags "&amp;lt;elenco&amp;gt;&amp;lt;/elenco&amp;gt;" of my String and fill an internal table. How can I do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help me please. THANKS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Andrea Ruocco on Jun 17, 2009 5:51 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Andrea Ruocco on Jun 17, 2009 5:53 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2009 15:47:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-xml-from-a-string/m-p/5797401#M1311086</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-17T15:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Read XML from a String</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-xml-from-a-string/m-p/5797402#M1311087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to create a XSLT Transformation and call that by passing your XML string and get the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lf_string TYPE string.
DATA: xml_string TYPE string.

lf_string = 'This single variable test'.

TRY.

* This call gets me the XML data. You need to skip this as you 
* already have the XML string
    CALL TRANSFORMATION ztest_np_xml2data
      SOURCE if_test = lf_string
      RESULT XML xml_string.

    CLEAR lf_string.

    CALL TRANSFORMATION ztest_np_xml2data
      SOURCE XML xml_string
      RESULT if_test = lf_string.

  CATCH cx_st_error.

ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Transformation ZTEST_NP_XML2DATA &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;?sap.transform simple?&amp;gt;
&amp;lt;tt:transform template="temp"
    xmlns:tt="http://www.sap.com/transformation-templates"
    version="0.1"&amp;gt;

  &amp;lt;tt:root name="IF_TEST"/&amp;gt;

  &amp;lt;tt:template name="temp"&amp;gt;
    &amp;lt;Test&amp;gt;
        &amp;lt;tt:value ref="IF_TEST" /&amp;gt;
    &amp;lt;/Test&amp;gt;
  &amp;lt;/tt:template&amp;gt;

&amp;lt;/tt:transform&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this example from Help: &lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/a4/1f1e400191f72ee10000000a1550b0/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/a4/1f1e400191f72ee10000000a1550b0/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2009 16:53:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-xml-from-a-string/m-p/5797402#M1311087</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-06-17T16:53:09Z</dc:date>
    </item>
  </channel>
</rss>

