0

I would like to use XSLT to transform some XML into JSON.

The XML looks like the following:

<root>
 <item>
   <number>123</number>
   <name>ABC</name>
   <EmployeeCode>
   <id>11</id>
   <Department>
         <Name>Zing</Name>
         <Age>42</Age>
         <Designation>Engineer</Designation>
    </Department>
    <Status>Contractor</Status>
   </EmployeeCode>
*Expecting like below*
<root>
 <item>
    <number>123</number>
    <name>ABC</name>
    <EmployeeCode>
        <id>11</id>
        "Department": {"Name": "Zing","Age": "42","Designation": "Engineer"}
        <Status>Contractor</Status>
    </EmployeeCode>
</item>
8
  • Which XSLT version, which XSLT processor do you use or can you use? With XSLT 3 it is easier than in previous versions to do it in a short and robust way. Commented Aug 6, 2021 at 16:20
  • Please ask a specific question about a difficulty you encountered when trying to accomplish this. Otherwise it looks like you're just looking for someone to write your code for you. Also, in all your questions regarding XSLT please state which version of XSLT your processor supports. Commented Aug 6, 2021 at 16:23
  • why don't you try wildcard on department/* and in for loop consider generating json string. Commented Aug 6, 2021 at 16:27
  • Looking closer it also is not quite clear at which point you want or have JSON in the output, the part with "Department" : doesn't look like quite like JSON. Commented Aug 6, 2021 at 16:27
  • I want to convert the Department structure into Json formate, the Main Structure should be in XML only, Commented Aug 6, 2021 at 17:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.