Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Need Unique Numbering based on XML Nodes

$
0
0

Hello Everyone,

I am stuck in one requirement where i have to provide unique id for the corresponding xml nodes. Lets say, my XML looks like this:

<?xml version="1.0"?><component><title>This is Test Title</title><body><p>A.</p><p>B.</p><figure><title></title><image/></figure><section><title>Test Title 2</title><p></p><p></p><note><head>NOTE</head><p></p></note><figure><title></title><image/></figure></section></body></component>

Now through XSLT i need to generate unique id's for each node. The output should look like this:

<?xml version="1.0"?><component id="1"><title id="2">This is Test Title</title><body id="3"><p id="4">A.</p><p id="5">B.</p><figure id="6"><title id="7"></title><image id="8"/></figure><section id="9"><title id="10">Test Title 2</title><p id="11"></p><p id="12"></p><note id="13"><head id="14">NOTE</head><p id="15"></p></note><figure id="16"><title id="17"></title><image id="18"/></figure></section></body></component>

We have same named elements that are in nesting too. Now how to generate unique id based on the position of node?

Thanks,





Shahab Abbasi



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>