Link to home
Start Free TrialLog in
Avatar of tia_kamakshi
tia_kamakshiFlag for United Arab Emirates

asked on

Extracting images based on last digit after substring with last _

Hi Experts,

I am working on ASP.net2.0 using C#

I need to extract images from my below xml
<?xml version="1.0" encoding="utf-8" ?>
<news type="detail">
	<article id="757236">
		<images>
			<image id="757233" type="M">
				<src><![CDATA[image01_tcm133-757233.jpg]]></src>
			</image>
			
			<image id="757231" type="M">
				<src><![CDATA[abc_02_tcm133-757231.jpg]]></src>
			</image>
			<image id="757232" type="M">
				<src><![CDATA[abc_xyz_tcm133-757232.jpg]]></src>
			</image>
			<image id="757233" type="M">
				<src><![CDATA[def3_tcm133-757233.jpg]]></src>
			</image>
			<image id="757234" type="M">
				<src><![CDATA[hig_htr3_thumb_tcm133-757234.jpg]]></src>
			</image>
		</images>
	</article>
</news>

Open in new window


to bring results as follows:

<div class="first2images">
<first>image01_tcm133-757233.jpg</first>
<second>abc_02_tcm133-757231.jpg</second>    
</div>

<div class="otherimages">
    abc_xyz_tcm133-757232.jpg
    def3_tcm133-757233.jpg
    xyz_thumb03_tcm133-757234.jpg
    hig_htr3_thumb_tcm133-757234.jpg
</div>

Open in new window


I mean, from images name, need to find last underscore ("_")

if before last underscore we will see the image name will be as follows:
      image01
      abc_02

      abc_xyz
      def3
      xyz_thumb03
      hig_htr3
      
      
the image name where in last 1 comes
should come in first node
<first>

image name where 2 comes, should come in node
<second>

and rest all other images to come in node
<div class="otherimages">


Please help me in this complicated xslt

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tia_kamakshi

ASKER

I wish to be your student. Don't know if it is possible

Works great.

Many Many thanks
Welcome

Getting the image name is just a recursive template that stops at the last '_'

The tricky thing about getting the numbered images is that I walk the following-sibling axis starting at the first image. The main advantage doing it this way is that you only continue to the next node under certain conditions... so I can stop when the first is found, or the second. Differentiation is through modes.

(I have done Skype coaching in the past, not regular training, but working through exercises to learn. Works pretty well. There is a "hire me" button somewhere around here if you want to discuss that)
Thanks Gertone

I really wanted to learn tricks you do.

How much your training costs. I am not finding any hire me button.

Please help me with it and I need to know the cost and how training will be done.

Thanks again
If you check the "about me" on my profile there is a web reference leading to my coordinates
Thanks Geert,

I got your details. I can see your next open training alredy happened in Dec 2011 and not seeing any details about future training

I will write you an email for next open training schedule

Regards,
Oh, that is open training in Dutch (open as in any one can subscribe)
Only have done training for private people and on site for companies since
Let's discuss over email
Hi Gertone,

I have sent you the email.

Thanks