I have run into a problem with XSLT transformation. I have input XML as bellow:
<root>
<photoname>image</photoname>
<photocount>3</photocount>
</root>
and i need transform it to following XML:
<root>
<response>
<images>
<image>
<small>image_1_120.jpg</small>
</image>
</images>
<images>
<image>
<small>image_2_120.jpg</small>
</image>
</images>
<images>
<image>
<small>image_3_120.jpg</small>
</image>
</images>
</response>
</root>
Is it possble to do with XSLT(or with C# functions in XSLT)?
You could achieve this in XSLT with a recursize template to iterate based on the photocount element
Try the following XSLT
When applied to your sample XML, the following is output:
Note that I didn’t know how the _120 suffix was generated, so I had to hard-code it in the XSLT.