plviji
2 years agoNew Contributor
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?