Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • GeetG 11 posts 91 karma points
    Apr 20, 2021 @ 08:22
    GeetG
    0

    How to convert JSON to XML using XSLT 1.0/2.0 ?

    Hi,

    I have to convert JSON to XML using XSLT 1.0. I have tried XSLT 3.0 but it doesn't work for me.

    Request:

    {
    
              "Text": [
    
                                   {
    
                                    "from":"784494",
    
                                    "to":"744111"
    
                                    }
    
                             ]
    
    }
    

    Expected Response:

    <?xml version="1.0" encoding="UTF-8"?>
    <Text>
    <from>9878744785</from>
    <to>998777945</to>
    </Text>
    

    XSLT I tried:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        exclude-result-prefixes="xs"
        version="3.0">
    
      <xsl:output indent="yes"/>
    
    
      <xsl:template match="/">
        <xsl:copy-of select="json-to-xml(root)"/>
      </xsl:template>
    
    </xsl:stylesheet>
    
  • Brendan Rice 537 posts 1098 karma points
    Apr 20, 2021 @ 09:31
    Brendan Rice
    0

    I never heard of Gateway script before. I googled it and found this:

    https://www.ibm.com/docs/en/acfc?topic=gatewayscript-code-examples

Please Sign in or register to post replies

Write your reply to:

Draft