<?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: Reading XML with ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-xml-with-abap/m-p/4077761#M975005</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Curious.  Something must be wrong with how I'm loading the XML file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In frustration I switched to another approach:  using 'SCMS_STRING_TO_XSTRING' and 'SMUM_XML_PARSE'.  This is working.  Go figure.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Jun 2008 13:40:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-30T13:40:08Z</dc:date>
    <item>
      <title>Reading XML with ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-xml-with-abap/m-p/4077759#M975003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got the XML file (below; second snippet) loaded into memory.  However, the call to l_rif_document-&amp;gt;find_from_path_ns( ) at the bottom of the first snippet returns nothing.  What must I do to return a reference to the root node so I can then loop the child nodes and get the data I need?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: l_rif_ixml      type ref to if_ixml,
      l_rif_factory   type ref to if_ixml_stream_factory,
      l_rif_parser    type ref to if_ixml_parser,
      l_rif_istream   type ref to if_ixml_istream,
      l_rif_document  type ref to if_ixml_document,
      l_rif_node      type ref to if_ixml_node,
      l_rif_element   type ref to if_ixml_element.

  " Create central factor object
  l_rif_ixml = cl_ixml=&amp;gt;create( ).

  " Create factory object for the data stream
  l_rif_factory = l_rif_ixml-&amp;gt;create_stream_factory( ).

  " Create input stream
  l_rif_istream = l_rif_factory-&amp;gt;create_istream_string( string = p_data_in ).

  " Create document
  l_rif_document = l_rif_ixml-&amp;gt;create_document( ).

  " Create XML parser
  l_rif_parser = l_rif_ixml-&amp;gt;create_parser( document        = l_rif_document
                                            stream_factory  = l_rif_factory
                                            istream         = l_rif_istream ).

  " Parse input stream
  l_rif_parser-&amp;gt;parse( ).

  l_rif_element = l_rif_document-&amp;gt;find_from_path_ns( default_uri = space*
                                                     *path = '/MYREPORT' ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And this is the XML document:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;MYREPORT&amp;gt;
	&amp;lt;RECORD&amp;gt;
	  &amp;lt;A-CARRIER-NAME&amp;gt;ACME HEALTH PLAN&amp;lt;/A-CARRIER-NAME&amp;gt; 
	  &amp;lt;B-CARRIER-CODE&amp;gt;DAI1&amp;lt;/B-CARRIER-CODE&amp;gt; 
	  &amp;lt;C-STATUS&amp;gt;Active Billing&amp;lt;/C-STATUS&amp;gt; 
	  &amp;lt;D-TYPE&amp;gt;1-PARTICIPANT&amp;lt;/D-TYPE&amp;gt; 
	  &amp;lt;E-NAME&amp;gt;DOE, JOHN&amp;lt;/E-NAME&amp;gt; 
	  &amp;lt;F-STREET-ADDRESS&amp;gt;100 MAIN STREET&amp;lt;/F-STREET-ADDRESS&amp;gt; 
	  &amp;lt;G-CITY&amp;gt;WESTON&amp;lt;/G-CITY&amp;gt;                                                         
	  &amp;lt;H-STATE&amp;gt;KY&amp;lt;/H-STATE&amp;gt; 
	  &amp;lt;I-ZIP&amp;gt;90210&amp;lt;/I-ZIP&amp;gt; 
	  &amp;lt;J-EMPLOYEE-ID /&amp;gt; 
	  &amp;lt;K-SSN&amp;gt;&amp;lt;/K-SSN&amp;gt; 
	  &amp;lt;L-ESSN&amp;gt;&amp;lt;/L-ESSN&amp;gt; 
	  &amp;lt;M-DOB&amp;gt;01-01-45&amp;lt;/M-DOB&amp;gt; 
	  &amp;lt;N-SEX&amp;gt;M&amp;lt;/N-SEX&amp;gt; 
	  &amp;lt;O-RELT&amp;gt;EMP&amp;lt;/O-RELT&amp;gt; 
	  &amp;lt;P-COVERAGE-TYPE&amp;gt;Medical&amp;lt;/P-COVERAGE-TYPE&amp;gt; 
	  &amp;lt;Q-OPTION-CODE&amp;gt;A&amp;lt;/Q-OPTION-CODE&amp;gt; 
	  &amp;lt;R-FAMILY-STATUS&amp;gt;3&amp;lt;/R-FAMILY-STATUS&amp;gt; 
	  &amp;lt;S-COBRA-CODE&amp;gt;C&amp;lt;/S-COBRA-CODE&amp;gt; 
	  &amp;lt;T-QE-DATE&amp;gt;01-31-08&amp;lt;/T-QE-DATE&amp;gt; 
	  &amp;lt;U-BENTERM-DATE&amp;gt;02-29-08&amp;lt;/U-BENTERM-DATE&amp;gt; 
	  &amp;lt;V-COBRA-ELIG-STARTS&amp;gt;03-01-08&amp;lt;/V-COBRA-ELIG-STARTS&amp;gt; 
	  &amp;lt;W-COBRA-ELIG-ENDS&amp;gt;08-31-09&amp;lt;/W-COBRA-ELIG-ENDS&amp;gt; 
	  &amp;lt;X-PAID-THRU&amp;gt;05-31-08&amp;lt;/X-PAID-THRU&amp;gt; 
	  &amp;lt;Y-GRACE-ENDING&amp;gt;07-02-08&amp;lt;/Y-GRACE-ENDING&amp;gt; 
	  &amp;lt;ZA-DIV&amp;gt;A1&amp;lt;/ZA-DIV&amp;gt; 
	  &amp;lt;ZB-UNIT&amp;gt;41&amp;lt;/ZB-UNIT&amp;gt; 
	  &amp;lt;ZC-CHANGE /&amp;gt; 
	  &amp;lt;ZD-FROM /&amp;gt; 
	  &amp;lt;ZE-TO /&amp;gt; 
	  &amp;lt;ZF-DOCID&amp;gt;43535234&amp;lt;/ZF-DOCID&amp;gt; 
	  &amp;lt;ZG-BENEFITS-CLASS /&amp;gt; 
	&amp;lt;/RECORD&amp;gt;
&amp;lt;/MYREPORT&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2008 13:50:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-xml-with-abap/m-p/4077759#M975003</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-27T13:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XML with ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-xml-with-abap/m-p/4077760#M975004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At first glance it seems all OK. So I've tried your code, and put some contents of your XML elements to a string variable. I've executed it and l_rif_element variable was correctly bound. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's your example, but declaring some XML elements inside the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: l_rif_ixml      type ref to if_ixml,
      l_rif_factory   type ref to if_ixml_stream_factory,
      l_rif_parser    type ref to if_ixml_parser,
      l_rif_istream   type ref to if_ixml_istream,
      l_rif_document  type ref to if_ixml_document,
      l_rif_node      type ref to if_ixml_node,
      l_rif_element   type ref to if_ixml_element.
DATA: lv_string       TYPE string.

  lv_string = '&amp;lt;MYREPORT&amp;gt;'.
  CONCATENATE lv_string '&amp;lt;RECORD&amp;gt;' INTO lv_string SEPARATED BY SPACE.
  CONCATENATE lv_string '&amp;lt;A-CARRIER-NAME&amp;gt;ACME HEALTH PLAN&amp;lt;/A-CARRIER-NAME&amp;gt;' INTO lv_string SEPARATED BY SPACE.
  CONCATENATE lv_string '&amp;lt;B-CARRIER-CODE&amp;gt;DAI1&amp;lt;/B-CARRIER-CODE&amp;gt;' INTO lv_string SEPARATED BY SPACE.
  CONCATENATE lv_string '&amp;lt;C-STATUS&amp;gt;Active Billing&amp;lt;/C-STATUS&amp;gt;' INTO lv_string SEPARATED BY SPACE.
  CONCATENATE lv_string '&amp;lt;J-EMPLOYEE-ID /&amp;gt;' INTO lv_string SEPARATED BY SPACE.
  CONCATENATE lv_string '&amp;lt;K-SSN&amp;gt;&amp;lt;/K-SSN&amp;gt; ' INTO lv_string SEPARATED BY SPACE.
  CONCATENATE lv_string '&amp;lt;/RECORD&amp;gt;' INTO lv_string SEPARATED BY SPACE.
  CONCATENATE lv_string '&amp;lt;/MYREPORT&amp;gt;' INTO lv_string SEPARATED BY SPACE.

  " Create central factor object
  l_rif_ixml = cl_ixml=&amp;gt;create( ).

  " Create factory object for the data stream
  l_rif_factory = l_rif_ixml-&amp;gt;create_stream_factory( ).

  " Create input stream
  l_rif_istream = l_rif_factory-&amp;gt;create_istream_string( string = lv_string ).

  " Create document
  l_rif_document = l_rif_ixml-&amp;gt;create_document( ).

  " Create XML parser
  l_rif_parser = l_rif_ixml-&amp;gt;create_parser( document        = l_rif_document
                                            stream_factory  = l_rif_factory
                                            istream         = l_rif_istream ).

  " Parse input stream
  l_rif_parser-&amp;gt;parse( ).

  l_rif_element = l_rif_document-&amp;gt;find_from_path_ns( default_uri = space
                                                     path = '/MYREPORT' ).
  lv_string = l_rif_element-&amp;gt;get_name( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards.&lt;/P&gt;&lt;P&gt;Bruno&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2008 03:09:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-xml-with-abap/m-p/4077760#M975004</guid>
      <dc:creator>BGarcia</dc:creator>
      <dc:date>2008-06-28T03:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XML with ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-xml-with-abap/m-p/4077761#M975005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Curious.  Something must be wrong with how I'm loading the XML file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In frustration I switched to another approach:  using 'SCMS_STRING_TO_XSTRING' and 'SMUM_XML_PARSE'.  This is working.  Go figure.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jun 2008 13:40:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-xml-with-abap/m-p/4077761#M975005</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-30T13:40:08Z</dc:date>
    </item>
  </channel>
</rss>

