English 中文(简体)
缩略语
原标题:XSLT RSS FEED - Combine substring-before and substring-after
  • 时间:2011-02-24 04:50:07
  •  标签:
  • xslt
  • rss

如果这个问题确实简单,我预先表示歉意,但我似乎无法找到解决这一问题的办法。

我需要一种办法,将Xsl的底线前线和下层功能结合起来,因此,在RSS饲料的描述中,我有一个起点和终点。

在每一种描述中,我都想从“财产所有权”的起算,但一旦达到第1条<代码>和t;b>。

我尝试了以下Xsl,但没有取得多大成功

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="channel">
<xsl:for-each select="item">


<xsl:value-of select=substring-after(description,  Primary Title:  />

<xsl:value-of select=substring-before(description,  &ltb&gt  />



</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

以下是XML。 我目前正在与我合作。

<rss version="2.0">
  <channel>
    <item>
      <title>Article_110224_081057</title>
    <description>
<![CDATA[<div><b>Description:</b>This is my description<b>Primary Title:</b>This is my primary title<b>Second Title:</b>This is my second title title </div>
]]>
</description>
    </item>
    <item>
      <title>Article_110224_081057</title>  
     <description>
<![CDATA[<div><b>Description:</b>This is my description<b>Other Title:</b>This is my other title<b>Second Title:</b>This is my second title titleb<b>Primary Title:</b>This is my primary title<b> more text </div>
]]>
</description>
    </item>
  </channel>
</rss> 
最佳回答

如果<b> 是标的,那么,由于tag子变成了 no子,你就能够利用子体配对找到灯。 如果是isn t a tag,那么你就只能将其与它相匹配,例如,它载于CDATA部分(你的例子似乎就是这样)。

问题回答

可帮助:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text"/>
    <xsl:template match="channel">
        <xsl:for-each select="item">
            <xsl:value-of select="
                substring-after(
                    substring-before(
                        substring-after(description,  Primary Title: ),
                         &lt;b 
                    ),
                     b&gt; 
                )
                "/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

抽样结果如下:

This is my primary titleThis is my primary title




相关问题
When test hanging in an infinite loop

I m tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here s the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> ...

quick xslt for-each question

Let s say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</...

XSLT Transform XML with Namespaces

I m trying to transform some XML into HTML using XSLT. Problem: I can t get it to work. Can someone tell me what I m doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/...

XSLT output to HTML

In my XSLT file, I have the following: <input type="button" value= <xsl:value-of select="name">> It s an error as it violates XML rule. What I actually want is having a value from an ...

Mangling IDs and References to IDs in XML

I m trying to compose xml elements into each other, and the problem I am having is when there s the same IDs. Basically what I need to do is mangle all the IDs in an xml file, as well as the ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签