Hi Experts,
This may be a silly question, but I can't seem to find a solution.
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 "<car>".
I can use:
RETURN_ELEMENTTYPE REF TO IF_IXML_ELEMENT
RETURN_ELEMENT = LO_DOCUMENT->FIND_FROM_NAME_NS( 'car' ).
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:
LO_NODE_COLLECTION TYPE REF TO IF_IXML_NODE_COLLECTION
LO_NODE_COLLECTION = LO_DOCUMENT->GET_ELEMENTS_BY_TAG_NAME_NS( 'car' ).
And now I have a Node's collection I can loop through and find the exact 'car' Element I want. Great.
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 IF_IXML_NODE.
After finding the 'car' Element I am looking for, by looping through the collection, how do I return this Node as an Element??
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?
Thanks!
-Kevin