<?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: XML Parsing Question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-parsing-question/m-p/11092676#M1902633</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My friend Paul J. Modderman helped me with this. I wish i could give you a 1000 points Paul, thank you!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just needed to cast the correct Node found in the collection as an Element in the way he expalined below:&lt;/P&gt;&lt;P&gt;DATA: LO_CAR_CURR_ELEMENT TYPE REF TO IF_IXML_ELEMENT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LO_CAR_CURR_ELEMENT ?= LO_NODE_COLLECTION-&amp;gt;GET_ITEM( LO_NODE_COLLECTION_INDEX ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again Paul!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Jun 2015 06:18:31 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2015-06-05T06:18:31Z</dc:date>
    <item>
      <title>XML Parsing Question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-parsing-question/m-p/11092675#M1902632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may be a silly question, but I can't seem to find a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a scenario where I am parsing XML in a custom Function Module. I am attemtping to return a specific Element from the XML, let's say "&amp;lt;car&amp;gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RETURN_ELEMENT&lt;SPAN class="L0S55"&gt; &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;REF &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TO&amp;nbsp; &lt;/SPAN&gt;IF_IXML_ELEMENT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;RETURN_ELEMENT &lt;SPAN class="L0S55"&gt;= LO_DOCUMENT&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;FIND_FROM_NAME_NS&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;'car' &lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S55"&gt;But, unfortunately that only returns the first 'car' Element in the XML. If I have say, 3 or 4, 'car' Elements, like one red, blue, yellow and black, then I need to loop through them to find the one I need to return. So, I use:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LO_NODE_COLLECTION &lt;SPAN class="L0S52"&gt;TYPE &lt;SPAN class="L0S52"&gt;REF &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;IF_IXML_NODE_COLLECTION&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LO_NODE_COLLECTION &lt;SPAN class="L0S55"&gt;= LO_DOCUMENT&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;GET_ELEMENTS_BY_TAG_NAME_NS&lt;SPAN class="L0S55"&gt;(&amp;nbsp; &lt;/SPAN&gt;'car' &lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S55"&gt;And now I have a Node's collection I can loop through and find the exact 'car' Element I want. Great.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S55"&gt;Now here is my problem, I still want my Function Module to return an IF_IXML_ELEMENT. But, even though my collection is a collection of Elements, it is a Node collection, so i have a &lt;/SPAN&gt;&lt;/SPAN&gt;IF_IXML_NODE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After finding the 'car' Element I am looking for, by looping through the collection, how do I return this Node as an Element??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not able to Cast, or I am not using the correct syntax to Cast. Has anyone done anything similar and can point me in the right direction?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2015 21:52:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-parsing-question/m-p/11092675#M1902632</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-06-04T21:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: XML Parsing Question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-parsing-question/m-p/11092676#M1902633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My friend Paul J. Modderman helped me with this. I wish i could give you a 1000 points Paul, thank you!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just needed to cast the correct Node found in the collection as an Element in the way he expalined below:&lt;/P&gt;&lt;P&gt;DATA: LO_CAR_CURR_ELEMENT TYPE REF TO IF_IXML_ELEMENT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LO_CAR_CURR_ELEMENT ?= LO_NODE_COLLECTION-&amp;gt;GET_ITEM( LO_NODE_COLLECTION_INDEX ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again Paul!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 06:18:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-parsing-question/m-p/11092676#M1902633</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-06-05T06:18:31Z</dc:date>
    </item>
  </channel>
</rss>

