Question: ```
<Document>
    <NodeA>1</NodeA>
    <NodeB>2</NodeB>
    <ServiceNode>3</ServiceNode>
    <NodeX>4</NodeX>
</Document>

```

I need to remove `ServiceNode` from the XML above using XSLT transformation. The output of the transformation should be:

```
<Document>
    <NodeA>1</NodeA>
    <NodeB>2</NodeB>
    <NodeX>4</NodeX>
</Document>

```

I have tried [this solution](https://stackoverflow.com/questions/4859831/how-to-write-a-xpath-to-match-all-elements-except-a-particular-element) and [this solution](https://stackoverflow.com/questions/1791108/xpath-expression-to-select-all-xml-child-nodes-except-a-specific-list) and did not get neither of those to work. The output value always still included the "excluded" nodes. What should I do to get this to work?

Answer: 
You didn't tell what your XSL looks like. Therefore, I guess that there is another error in it?!

Using the following code, you can eliminate `<ServiceNode>` by applying an empty template.

```
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>

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

    <xsl:template match="ServiceNode"/>
</xsl:stylesheet>

```
If Anyone is still looking at this, use `<xsl:strip-space elements="*"/>` to make sure there are no empty lines in XML once the tags are removed and use `<xsl:output method="xml" indent="yes"/>` to preserve the indentation. Below is a possible solution.

```
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
    <xsl:output method="xml" indent="yes"/>

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

    <xsl:template match="ServiceNode"/>
</xsl:stylesheet>

```