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 8274279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:41:23+00:00 2026-06-08T07:41:23+00:00

Hi I require help parsing the following XML. <xmeml> <Doc> <Test> <Unit>abc</Unit> <Unit2>1234</Unit2> </Test>

  • 0

Hi I require help parsing the following XML.

<xmeml>
<Doc>
    <Test>
        <Unit>abc</Unit>
        <Unit2>1234</Unit2>
    </Test>
    <Test>
        <Unit>bcd</Unit>
        <Unit2>2345</Unit2>
    </Test>
</Doc>
<Doc>
    <Test>
        <Unit>abc</Unit>
        <Unit2>3456</Unit2>
    </Test>
    <Test>
        <Unit>cde</Unit>
        <Unit2>3456</Unit2>
    </Test> 
</Doc>
<Doc>
    <Test>
        <Unit>abc</Unit>
        <Unit2>1234</Unit2>
    </Test>
    <Test>
        <Unit>def</Unit>
        <Unit2>4567</Unit2>
    </Test> 
</Doc>
<Doc>
    <Test>
        <Unit>abc</Unit>
        <Unit2>1234</Unit2>
    </Test>
    <Test>
        <Unit>efg</Unit>
        <Unit2>2345</Unit2>
    </Test> 
</Doc>
</xmeml>

ending up with the following

<xmeml>
<Doc>
    <Test>
        <Unit>bcd</Unit>
        <Unit2>2345</Unit2>
    </Test>
</Doc>
<Doc>
    <Test>
        <Unit>abc</Unit>
        <Unit2>3456</Unit2>
    </Test>
    <Test>
        <Unit>cde</Unit>
        <Unit2>3456</Unit2>
    </Test> 
</Doc>
<Doc>
    <Test>
        <Unit>def</Unit>
        <Unit2>4567</Unit2>
    </Test> 
</Doc>
<Doc>
    <Test>
        <Unit>abc</Unit>
        <Unit2>1234</Unit2>
    </Test>
    <Test>
        <Unit>efg</Unit>
        <Unit2>2345</Unit2>
    </Test> 
</Doc>
</xmeml>

I am attempting to create a XSLT doc to do this but as yet have not found one that works.
I should note that the required matching parameters within ‘Doc’ are , in this case “abc” and “1234′, In the real world these are variables and will never be a static searchable entity.

So in english my XSL would be like this:
For any parent containing both matching ‘Unit’ and ‘unit2’ values
delete all preceding parents ‘Test’ containing a duplicate value of ‘Unit’ and ‘Unit2’ except the last.

All help most appreciated
Thanks

  • 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-06-08T07:41:24+00:00Added an answer on June 8, 2026 at 7:41 am

    Here’s a relatively simple way of doing it, although I’m fairly sure there’s a more efficient way using the Meunchian method. If performance isn’t an issue however, this is probably easier to follow:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml"/>
    
      <xsl:template match="Test">
        <xsl:variable name="vUnit" select="Unit" />
        <xsl:variable name="vUnit2" select="Unit2" />
        <xsl:if test="not(following::Test[Unit = $vUnit and Unit2 = $vUnit2])">
          <xsl:call-template name="identity" />
        </xsl:if>
      </xsl:template>
    
      <xsl:template match="@* | node()" name="identity">
        <xsl:copy>
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
    </xsl:stylesheet>
    

    The Test template simply checks if there’s a later Test element with the same values in Unit and Unit2, and if there isn’t, it outputs it as normal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code for parsing an XML file. But I don't
I am using the following code for parsing of small xml files and it
I require help to search a text file (log file) using c# and display
Require a huge help here, since this is affecting our production instance. One of
Please help me with fixing the following error: This Android SDK requires Android Developer
require installed gems are not visible. Test with hpricot which I installed several times:
I am facing a peculiar problem in parsing some xml data within my iPhone
I am using libxml-ruby for parsing XML. I can able to create the xml
XML parsing in Scala doesn't seem to be as easy and straightforward as it
Liferay migration from one server to another help required. Can anyone share there steps

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.