SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get the image source out of this code:

        <span><img width="200" src="..."></span><br /> [some Text] ]]>

This is what I tried:

 <xsl:variable name="ImageURL" select="substring-before(substring-after(content, 'src=&quot;'), '&quot;&gt;')" />
 <img alt="" src="{$ImageURL}" width="75" height="49" />

Unfortunately my solutions failed. I also tried some other syntax but the main part was the same. Could anybody help me please?

Thanks for all effort!

share|improve this question
<item> <title><![CDATA[ ... ]]></title> <link></link> <content:encoded> <![CDATA[ <span><img width="200" src="..."></span><br />]]> </content:encoded> <pubDate></pubDate> <category>feed_theme</category> <author></author> <guid> This is one feeditem what "namespace" do you mean? Or do you mean the feedURL? </guid> </item> – Felix Zeidler Dec 13 '12 at 21:22
up vote 2 down vote accepted

Your xslt should be something like:

<xsl:variable name="ImageURL" xmlns:content="http://namespaceurl" select="substring-before(substring-after(content:encoded, 'src=&quot;'), '&quot;')" />
<img alt="" src="{$ImageURL}" width="75" height="49" />

Where http://namespaceurl matches the namespace "url" of content from the input

To find that namespace url look at the input xml it'll define the xmlns:content somewhere like this:

<rss version="2.0" xmlns:content="">

If this is how it's defined then is the namespace url and your xslst should contain:

<xsl:variable name="ImageURL" xmlns:content="" select="substring-before(substring-after(content:encoded, 'src=&quot;'), '&quot;')" />
<img alt="" src="{$ImageURL}" width="75" height="49" />
share|improve this answer
Please look at my answer above. – Felix Zeidler Dec 13 '12 at 21:23
Good work! Works perfect, thanks so much! – Felix Zeidler Dec 14 '12 at 12:58

I have the same problem. But the namespaceurl looks different in my xml source. I have this one:

rss version="2.0" xmlns:atom=""

Then, follow the solution, I use:

<xsl:variable name="ImageURL" xmlns:atom=""  select="substring-before(substring-after(atom:encoded, 'src=&quot;'), '&quot;')" />
   <img alt="" src="{$ImageURL}" width="60" height="60" />

But when I see the code for the web page, I have:

  <img alt="" src="" width="60" height="60" />
share|improve this answer
Could you please provide us the sourcecode of your IMG-Tag you try to read out? – Felix Zeidler Mar 25 '13 at 8:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.