Forum Discussion

plviji's avatar
plviji
New Contributor
2 years ago

To convert Json to XML with multiple attribute elements with ids and values

 

Json: 
"name": "Company Name",
"addressLine1": "10 North Street",
"addressLine2": null,
"city": "Washington",
"state": "DC",
"postalCode": "12345",
"country": "USA"

Expected XML:
<VocabularyElement id="urn:epc:id:sgln:77777.111111.0"> <attribute id="urn:epcglobal:cbv:mda#name">Company Name</attribute> <attribute id="urn:epcglobal:cbv:mda#streetAddressOne">10 North Street</attribute> <attribute id="urn:epcglobal:cbv:mda#streetAddressTwo">Room 378</attribute> <attribute id="urn:epcglobal:cbv:mda#city">Washington</attribute> <attribute id="urn:epcglobal:cbv:mda#state">DC</attribute> <attribute id="urn:epcglobal:cbv:mda#postalCode">12345</attribute> <attribute id="urn:epcglobal:cbv:mda#countryCode">USA</attribute> </VocabularyElement>

I have tried using XML generator with the expected XML, able to get the expected result, but when I pass it through AS2 sender, it adds element=3d in all tags.
So I started using XML formatter, not able to get the expected XML tags.


<VocabularyElement>
<name>Company Name</name>
<addressLine1>10 North Street</addressLine1>
<addressLine2/>
<city>Washington</city>
<state>DC</state>
<postalCode>12345</postalCode>
<country>USA</country>
</VocabularyElement>

Can anyone help me on this?

2 Replies

  • Hi plviji ,

    I created a sample pipeline with what you mentioned and I invoked this pipeline in POSTMAN. The result XML doesn't have element=3d in any tags.

    Could it be possible that it is getting appended in the target system?

    Below is the response from Postman:

    XML Generator:

    Mapper Expression:

    Make sure the output view of mapper is binary.

    Hope this helps.

    Thanks,

    Abhishek

  • plviji's avatar
    plviji
    New Contributor

    Hi Abhishek_Soni37,

    Once I convert thru XML Generator - I have to send the file thru AS2 sender - that's were element=3d getting added to all tags