CA API Management: Remove XML elements using XSLT

book

Article ID: 16621

calendar_today

Updated On:

Products

STARTER PACK-7 CA Rapid App Security CA API Gateway

Issue/Introduction



How can you remove XML elements using XSLT?

Environment

Release: L7SGA299000-8.4-API Gateway SOA Gateway-HARDWARE APPLIANCE DUAL CPU
Component:

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.

<Please see attached file for image>

src="/servlet/servlet.FileDownload?file=0150c000004AKpYAAW" alt="xml.png" width="577" height="428">

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>

 

 

<Please see attached file for image>

src="/servlet/servlet.FileDownload?file=0150c000004AKpZAAW" alt="xslt.png" width="761" height="744">

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