cancel
Showing results for 
Search instead for 
Did you mean: 

Split XML into multiple records

former_member235717
Participant
0 Kudos

Hi All,

I have to split an XML field from a data type into multiple records on the target side.

For eg: If the source XML string is something like this:

<XML_STRING>

<Data>

   <name>abc</name>

   <place></place>

         <addr1> </addr1>

         <addr2></addr2>

    </place>

   <name>xyz<name>

   <place>

         <addr1></addr1>

         <addr2></addr2>

     </place>

</Data>

</XML_STRING>

Since the above XML string has two records in it (each record includes name and place), I would like to split those two into two separate records in the target structure and send it to ECC.

How can I achieve this in PI mapping. Here in this case I cannot even differentiate between <> </> to split the messages since a single records might have multiple sub nodes in it. It is only believed that when "<name>" repeats again in the XML that would be a start of new record. Based upon that I need to split the records.

Thanks in advance!!

Accepted Solutions (1)

Accepted Solutions (1)

former_member187010
Participant
0 Kudos

Hi Shweta,

Minor correction is required for you source structure. Please follow Amit or Vila suggestion for content conversion.

Did mapping as per your requirement. Please find the screen shot below. Please note the structure and cardinality of the element and node field.

Hope result is as per your requirement.

Regards

Jitender

Answers (3)

Answers (3)

former_member235717
Participant
0 Kudos

Thank you all!! It helps alot

iaki_vila
Active Contributor
0 Kudos

HI Swetha,

First of all your source XML is incorrect if the DATA tag has like value a CDATA structure. You should to check what is the source, if the source is a file and you use a file content conversion you could change in a more friendly structure.

If you have that field with CDATA you can follow Amit suggestion with XSL, also you can use a java mapping or udf, in google you will find a lot of examples.

Finally, i suppose you are using an RFC or inbound proxy. With RFC you would use a internal table, it will easy because you will have so much item like name tags for example and the mapping will be direct. If you will use a inbound proxy you can choose a similar structure like an internal table with a 0..unbound tag.

Regards.

Former Member
0 Kudos

Hello,

First of all, using xslt code convert xml string data into XML structure and then u can map intermediate structure (generated using above XSLT code) with ur target and create multiple records (i think u have to use UDF to map intermediate structure XML to ur target)

Thanks

Amit Srivastava