2012 Feb 03 8:57 AM
Hi All,
I have a requirement to convert XML to itab to be processed further.
I couldn't parse the XML which contains ns0 (namespace?) as following:
<ns0:OrderNo>887140</ns0:OrderNo>
<ns0:CPROD>BD</ns0:CPROD>
<ns0:CURR>USD</ns0:CURR>
I'm able to parse If I remove the namespace ns0 from the file as following:
<OrderNo>887140</OrderNo>
<CPROD>BD</CPROD>
<CURR>USD</CURR>
The thing is the XML file will always come with the namespace ns0.
I'm using IF_IXML, IF_IXML_STREAM_FACTORY, IF_IXML_ISTREAM, IF_IXML_PARSER, IF_IXML_DOCUMENT to parse the XML.
Any idea on how to overcome this?
Thanks,
Victor.
2012 Feb 03 9:09 AM
Hello Victor,
try to use XSLT Transformations.
Thereby you will gain a lot of features, including the XSLT-Editor and a very smooth integration in ABAP.
Kind regards,
Hendrik
Hi All,
I have a requirement to convert XML to itab to be processed further.
I couldn't parse the XML which contains ns0 (namespace?) as following:
<ns0:OrderNo>887140</ns0:OrderNo>
<ns0:CPROD>BD</ns0:CPROD>
<ns0:CURR>USD</ns0:CURR>
I'm able to parse If I remove the namespace ns0 from the file as following:
<OrderNo>887140</OrderNo>
<CPROD>BD</CPROD>
<CURR>USD</CURR>
The thing is the XML file will always come with the namespace ns0.
I'm using IF_IXML, IF_IXML_STREAM_FACTORY, IF_IXML_ISTREAM, IF_IXML_PARSER, IF_IXML_DOCUMENT to parse the XML.
Any idea on how to overcome this?
Thanks,
Victor.
2012 Feb 03 9:09 AM
Hello Victor,
try to use XSLT Transformations.
Thereby you will gain a lot of features, including the XSLT-Editor and a very smooth integration in ABAP.
Kind regards,
Hendrik
2012 Feb 03 9:29 AM
Hi Hendrik,
Thanks for your reply.
I haven't try to use XSLT for this. But Sure I will try this in the future.
As for my case now,
The XML is quite complex and I have build a FM by using standard SAP class mentioned earlier to parse and assign the value dynamically to the internal table. Everything works fine when all the tag doesn't come out with the namespace ns0.
I'm thinking I might missed out something to tell SAP during parsing the XML that this XML document is comes with namespace ns0.
Thanks,
Victor.
2012 Feb 03 10:39 AM
Dear All,
I've solved my problem.
I just need to pass the namespace ('ns0' in my case) during search of the tag.
Interface: IF_IXML_DOCUMENT
Method get_elements_by_tag_name( name = xml_row namespace = namespace ).
Thanks,
Victor.
2012 Feb 03 11:11 AM
Hello Victor,
fine. I am glad, I could help you.
Just one note to XSLT Transformations: When using them, you got even the ability to map directly to internal abap tables:
CALL TRANSFORMATION ZXSLT_YOUR_TRANSFORMATION
SOURCE XML l_xmlstring
RESULT DATA = lt_data.
You just need to transform you xml to the asx:abap name space and that's it
Look at , where I show a simple example, how this works.
Kind regards,
Hendrik
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |