on 02-10-2017 4:28 PM
If i am getting input like below
<Root>
<row>
<field>A</field>
</row>
<row>
<field>B</field>
</row>
<row>
<field>A</field>
</row>
</Root>
Then i want output like this
<Root>
<row>
<field>B</field>
</row>
</Root>
Is it possible through xslt or xsd validation?
Hi Aditya!
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<Root>
<xsl:apply-templates select="//field[not(text()=preceding::text()) and not(text()=following::text())]"/>
</Root>
</xsl:template>
<xsl:template match="field">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Source:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<row>
<field>A</field>
</row>
<row>
<field>B</field>
</row>
<row>
<field>A</field>
</row>
<row>
<field>C</field>
</row>
<row>
<field>D</field>
</row>
<row>
<field>C</field>
</row>
</Root>
Result:
<?xml version="1.0" encoding="utf-8"?><Root><field>B</field><field>D</field></Root>
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.