CA API Management: Remove XML elements using XSLT
search cancel

CA API Management: Remove XML elements using XSLT

book

Article ID: 16621

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

This KB article outlines how to remove XML elements using XSLT.

Environment

All supported versions of the API Gateway

Resolution

Given the below XML, this XSLT can be used to remove particular elements from XML. In this example, the "author" and "year" tags will be removed.

You can customize these values to meet your needs.

XML

<bookstore>

<book category="API">

   <title lang="en">CA API Management</title>

   <author>John Doe</author>

   <year>2017</year>

   <price>30.00</price>

</book>

</bookstore>

XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output indent="yes" omit-xml-declaration="yes"/>

 <xsl:template match="node()|@*">

  <xsl:copy>

   <xsl:apply-templates select="node()|@*"/>

  </xsl:copy>

 </xsl:template>

 <xsl:template match="author|year"/>

</xsl:stylesheet>

 

 

Attachments

1558717101573000016621_sktwi1f5rjvs16ug3.png get_app
1558717099601000016621_sktwi1f5rjvs16ug2.png get_app