Need help to read the XML payload which is coming inside one of the field.
Request Payload:
<?xml version="1.0" encoding="UTF-8"?>
<Code xmlns:ns0="http://example.com">
<Header>
<Field1>111</Field1>
<Field2>text</Field2>
</Header>
<Trailer>
<?xml version="1.0" encoding="UTF-8"?>
<Field4>
<Field5>
<Field6>Age</Field6>
<Field7>Location</Field7>
<Field6>Age</Field6>
<Field7>Location</Field7>
</Field5>
</Field4>
</Trailer>
</Code>
Above is the Request XML payload in which we have field called
<Trailer>where we are again getting an XML payload. We need to fetch only the selected fields from the XML payload which is in the<Trailer>field and generate below Output.Expected Output Payload:
<?xml version="1.0" encoding="UTF-8"?>
<Code xmlns:ns0=http://example.com>
<Header>
<Field1>111</Field1>
<Field2>text</Field2>
</Header>
<Field5>
<Field6>Age</Field6>
<Field7>Location</Field7>
<Field6>Age</Field6>
<Field7>Location</Field7>
</Field5>
</Code>
I tried with below XSLT but I am unlucky to fetch the required fields from the <Trailer> field
XSLT Code:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<Code>
<xsl:copy-of select="//Header" />
<xsl:value-of select="//Trailer" disable-output-escaping="yes"/>
</Code>
</xsl:template>
</xsl:stylesheet>
Try this.