I want to apply a XSL style sheet that delete duplicate nodes in my xml.
I test some solution but i can’t do it 🙁 my program is in Visual C# Studio.
I have the following XML:
<store>
<laptop>
<ID>1</ID>
<price>X2</price>
</laptop>
<laptop>
<ID>2</ID>
<price>X1</price>
</laptop>
<laptop>
<ID>8</ID>
<price>X2</price>
</laptop>
<laptop>
<ID>2</ID>
<price>X3</price>
</laptop>
</store>
The desired output is:
<store>
<laptop>
<ID>1</ID>
<price>X2</price>
</laptop>
<laptop>
<ID>8</ID>
<price>X2</price>
</laptop>
<laptop>
<ID>2</ID>
<price>X3</price>
</laptop>
</store>
The solution below does what you are asking for and works the following way:
not have a ID tag below with the same value (thats why ID 2 comes at
the end of the output)
and all of it’s children
Comments are welcome, this is my first try at XSL in the last two years.
I tried a xsl:copy but it failed to include the children’s tag names, but the values showed up, couldn’t figure out why!?
Taken somewhat out of it’s contents:
Working code: