Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

<content:encoded>
    <![CDATA[
        <span><img width="200" src="..."></span><br /> [some Text] ]]>
</content:encoded>

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

2 Answers 2

up vote 1 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="http://purl.org/rss/1.0/modules/content/">

If this is how it's defined then http://purl.org/rss/1.0/modules/content/ is the namespace url and your xslst should contain:

<xsl:variable name="ImageURL" xmlns:content="http://purl.org/rss/1.0/modules/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="http://www.w3.org/2005/Atom"

Then, follow the solution, I use:

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

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

<li> 
  <img alt="" src="" width="60" height="60" />
</li>
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

 
discard

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.