Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • María 3 posts 23 karma points
    Mar 23, 2013 @ 14:12
    María
    0

    Extract src from CDATA in XML file

    Hello,

    I have this xml code:

    <description><![CDATA[<p>
    <img style="margin: 10px;
         float: left;" alt="Nuevo modelo general de negocio"
         src="http://mysite.es/images/figure1.jpg" width="196" height="147" />
         La compañía apuesta por un marcado giro en el modelo]]>
    </description>

    And I have this xslt script:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        exclude-result-prefixes="xsl">
        <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
        <xsl:template match="/">
            <div>
               <xsl:apply-templates select="rss/channel"/>
            </div>
        </xsl:template>
        <xsl:template match="rss/channel">
            <xsl:variable name="link" select="link"/>
            <xsl:variable name="description" select="description"/>

            <ul><xsl:apply-templates select="item"/></ul>
        </xsl:template>
        <xsl:template match="item">
            <xsl:variable name="item_link" select="link"/>
            <li>
      
                <a href="{$item_link}" "><xsl:value-of select="title"/></a>
            </li>
        </xsl:template>
    </xsl:stylesheet>

     

    I need to read the src property to put the image, before the link in the LI list.

    Thank you in advanced.

    Regards,

    María

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 23, 2013 @ 15:49
    Jan Skovgaard
    0

    Hi Maria

    Could you please provide the full XML structure from your feed? Just one <item></item> element with all of it's content. I just need to see the whole structure in order to suggest how you can try and solve your issue.

    Looking forward to hearing from you.

    /Jan

  • María 3 posts 23 karma points
    Mar 23, 2013 @ 15:59
    María
    0

    Hello Jan,

    thanks for your response! Here is the xml

     

    <?xml version="1.0" encoding="utf-8"?>
    <!-- generator="FeedCreator 1.8.0-dev ([email protected])" -->
    <rss version="2.0"  xmlns:atom="http://www.w3.org/2005/Atom">
        <channel>
            <title>RSSNoticiasCORE</title>
            <description></description>
            <link>http://mysite/</link>;
            <lastBuildDate>Sun, 24 Mar 2013 16:45:08 GMT</lastBuildDate>
            <generator>FeedCreator 1.8.0-dev ([email protected])</generator>
            <image>
                <url>[Tab]</url>
                <title>Empresa SLU</title>
                <link>http://mysite/</link>;
                <description><![CDATA[Nombreain SLU]]></description>
            </image>
      <atom:link href="http://mysite/index.php?option=com_ninjarsssyndicator&amp;feed_id=2&amp;format=raw&amp;lang=es" rel="self" type="application/rss+xml" />       
            <item>
                <title>Liderazgo </title>
                <link>http://mysite/index.php?option=com_content&amp;view=article&amp;id=108:liderazgo-&amp;catid=77:noticias&amp;Itemid=662&amp;lang=es</link>;
                <description><![CDATA[<p style="text-align: justify;"><img alt="" align="left" src="http://mysite/images/casos_exito/13/golf.jpg" />El ranking de la revista Computerworld, el primero que ofrece datos globales sobre el sector TIC español, confirma un]]></description>
       <pubDate>Mon, 18 Mar 2013 11:09:25 GMT</pubDate>
                <guid isPermaLink="false">http://mysite/index.php?option=com_content&amp;view=article&amp;id=108:liderazgo&amp;catid=77:noticias&amp;Itemid=662&amp;lang=es</guid>;
            </item>
        </channel>
    </rss>

     

     

     

    Regards,

    María

  • María 3 posts 23 karma points
    Mar 26, 2013 @ 11:58
    María
    0

    Hello, some idea about this answer?

    Regards,

    María

Please Sign in or register to post replies

Write your reply to:

Draft