In the above XML, contains 3 tags that are ID, RelID and Category.
The one which does have have RelID, that becomes parent and the one that has some value becomes the child
Example: In the above example:
0001 is the parent
and
003
0001
Child
003, is the child for parent 0001.
Requirement is to convert the xml data to the following structure as attached in the screenshot. Any suggestion/code on how to proceed further with the logic here?
In the attached structure, we need to append the children to the respective parents in a hierarchy manner
In your sample, you have two parents (RelID is empty), then?
Question to you - are you converting the IData (the one in the screen shot) back to xml, if so what is the expected final xml structure? and what is next step in once you get the desired IData structure?
The approach I think is by flow or using the XSL mapping, but need to understand the data structure that comes and what is expected out of it.
As per the SS the final xml structure should looks like deep recursive of Components/Component this correct? →
– Parent
<Component) - DocList - Deep recursive Loop
-
So now as per your source XMLdata map to the Target XMLdata and give your expected outcome instead of saying parent/child relation ship with the tags you narrated above:
If the RelatedID (RID) is empty, which means its the parent and we can have any number of parents.
As rmg said, its a deep recursive, that is any number of parents can have any number of children and any number of children can have any number of sub-children and so on.
First we get XML data and then “apply the logic” (depends on each developer) and finally convert the XML data to the target structure, as shown in the screenshot attached.
I have also attached the target structure one more time.
Problem here is: we tried all possible ways of dealing with ideas/code, but we are unable to end up to map to target structure, as we are not able to find how to insert into a document i.e child and sub child model.
Any small demo code will help a lot and unblock our development please.
Hope this helps, managed to populate the IData structure (if this is the expected) for the below sample (one parent with multiple childrens), share me the xml sample with multiple parents and childrens, how each parent is linked with their respective childrens.
Feel free to contact me on email and I can be of some help if I can.
I understand this is a complex XML with parent/child (recursive scenario) is your target system is expecting this way of format?
But I believe you are in a right path using XSLT Transformation handling of this kind of xml complexity.
Will also take a look on the error apart from Mahesh