on 10-25-2017 7:27 PM
HiExperts,
I have below xml structure
<head><item><f1>a</f1><f2>b</f2></item><item><f1>c</f1><f2>d</f2></item></head>
I want the "item" nodes to be reversed,i.e.,from last to first.Please help me with the relevant for the same.
ThankYou.
Ahmed
Hi Ahmed!
This can be easily done using XSL transformation:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<head>
<xsl:apply-templates select="/head/item">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</head>
</xsl:template>
<xsl:template match="item">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Result (according to your test data provided above):
<?xml version="1.0" encoding="utf-8"?>
<head>
<item>
<f1>c</f1>
<f2>d</f2>
</item>
<item>
<f1>a</f1>
<f2>b</f2>
</item>
</head>
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Farooq,
If my understanding is not wrong you just to wish to reverse ITEMS Note.Try the below approach
UDF(All Values of Queue):
for(int i=var1.length-1;i>=0;i--)
{
result.addValue(var1[i]);
}
Map it to F1 and F2 Nodes
Sample Input and Output:
If this is not the requirement please post the sample input and output XMLs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.