on ‎2021 Sep 22 4:33 PM
Hello Team,
I need to read a heavy XML file in SAP Data intelligence v 3.1.
As there are no standard operators to acheive this, what is teh best approach?
Thanks,
Indu K.
Request clarification before answering.
Hi Indu ,
I assume you are able to read the file and tried to fetch relevant information form xml file using standard DI operators and it did not meet you needs , I will suggest you to go with custom python logic to retrieve information from xml file .
Thanks
Shakti Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Indu,
it would be feasible to use a Python Operator in Data Intelligence Pipelines for parsing the XML payload.
With the help of the Python ElementTree XML API library, you can browse through the XML document structure and extract attributes and/or values for all nodes on all levels. Here is the documentation.
The general approach is
The library documentation linked above is a nice source for guidance covering various different use cases with many example code snippets.
Implementing code in Python Operators may not be the most convenient approach, but the treatment of nested hierarchical XML structures isn't really trivial and can't easily be provided by standard operators.
Kind Regards,
Bengt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Indu,
You could try to use Format Converter operator to convert file from XML to CSV and then process.
Best,
Michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Michal,
Thank you for your answer.I have tried this approach using format converter but the issue is with attributes and missing nodes in the deep XML structure. With a structure like below, the value of attribute at third level is captured in json through format converter but is not passed into CSV:
<root>
<child attr = "">
<subchild>.....</subchild>
</child>
<child attr = "">
<subchild>.....
<sub-subchild>
<sub-sub-sub child attr ="">
<element1>mm</element1>
<element2>nn</element2>
</sub-sub-sub child>
</sub-subchild>
</subchild>
</child> </root>
In hierarchical structure of the XML.
My requirement is to parse the xml and load the data in HANA table.
Thanks for your help!
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.