Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to add an additional xml node into xml response received from target endpoint

Not applicable

Final response should be xml response received from called target endpoint plus an additional xml tag indicator with fixed boolean value.Please suggest

How to add an additional xml node into xml response received from target endpoint

Solved Solved
0 3 2,937
1 ACCEPTED SOLUTION

@paridhi agarwal, you can use a generic xsl transformation that just adds your new element to the root element (whatever that may be) and copies all its children: (XSLT adapted from https://stackoverflow.com/questions/25957167/xslt-to-add-new-elements-to-the-root-element-of-an-xml)

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <!-- match the root element of unknown name -->
  <xsl:template match="/*">
     <xsl:copy>
       <!-- copy its children -->
       <xsl:copy-of select="@*|node()"/>
       <!-- add a new element at the end -->
       <name>abc</name>
     </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

View solution in original post

3 REPLIES 3