Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7561133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:05:25+00:00 2026-05-30T13:05:25+00:00

for example below is the xml <products> <product> <name>Pen</name> <Quantity>2</Quantity> <Amount><Price>2</Price><Currency>USD</Currency></Amount> </product> <product> <name>Pencil</name>

  • 0

for example below is the xml

<products>
    <product>
        <name>Pen</name>
        <Quantity>2</Quantity>
        <Amount><Price>2</Price><Currency>USD</Currency></Amount>
    </product> 
    <product>
        <name>Pencil</name>
        <Quantity>20</Quantity>
        <Amount><Price>2</Price><Currency>USD</Currency></Amount>
    </product>
    <product>
        <name>Bag</name>
        <Quantity>25</Quantity>
        <Amount><Price>2</Price><Currency>USD</Currency></Amount>
    </product>
</products>

in my xsl i using like below to remove

<xsl:copy-of select="node()[not(self::Quantity)]"/>

I also need to remove sub node <Currency> from the <Amount>

i try like below

<xsl:copy-of select="node()[not(self::Quantity) and not(self::Amount/Currency)]"/>

but not working fine . it will remove all node’s from <Amount>

How i remove sub node <Currency> only?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:05:26+00:00Added an answer on May 30, 2026 at 1:05 pm

    If you really want to use self

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

    or if you want to know other simpler way 🙂

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

    The above templates copy all other tags except <Currency>

    EDIT: Replace the below code

    <xsl:template match="product">
       <product>
        <xsl:for-each select="key('kProdByName', name)">
          <xsl:if test="position() = 1">
            <xsl:copy-of select="node()"/>
          </xsl:if>
        </xsl:for-each>
       </product>
    </xsl:template>
    

    By this: (hope it works)

      <xsl:template match="product">
        <product>
          <xsl:for-each select="key('kProdByName', name)">
            <xsl:if test="position() = 1">
              <xsl:apply-templates select="node()|@*"/>
          </xsl:if>
          </xsl:for-each>
        </product>
      </xsl:template>
    
      <xsl:template match="Currency|Quantity"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the XML/RDF example below taken from the W3C website, how can I access
My current LINQ query and example XML are below. What I'd like to do
I'm traversing an xml file as below: <?xml version=1.0 encoding=ISO-8859-1?> <wrapper> <site base=http://www.example1.co.uk/ name=example
In this example below: my $rs = $schema->resultset('CD')->search( { 'artist.name' => 'Bob Marley' 'liner_notes.notes'
In the XML example below, using a java parser how to keep the content
I have unusual format of XML as below example <mainmenu> <menu caption=File> <menuitem caption=New
I have an XML file (example below) and it is sitting somewhere on the
The class example below MyAppender is called from the logback.xml file. When the append()
I'm trying to parse some HTML with XPath. Following the simplified XML example below,
updated below Does anybody have an example of proper XML for the Magento SOAP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.