XSLT remove elements that do not match regex
问题 I want a simple XSLT which will only keep the elements which contain a certain regex: <example> <abc>text</abc> <bc>text</bc> <ab>text</ab> </example> I want the same XML output but only with the elements which contain an "a": <example> <abc>text</abc> <ab>text</ab> </example> 回答1: Start with the identity transform and add a template that suppresses elements whose name does not match your regex: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org