如何使用substring-after()函数?我直接在代码中写:text = substring-after(Text, ">");总提示上下文中不存在名称“substring”

解决方案 »

  1.   

    不能直接在代码中用,应该是在xml-schema中用的
      

  2.   

    我想得到text字符串中">"后面的子串
      

  3.   

    Sample code as follows:text = yourString.SubString( yourString.LastIndexOf( '>' ) + 1 );
      

  4.   

    Sample code as follows more safe:int nIndex = yourString.LastIndexOf( '>' );
    if( nIndex >= 0 && nIndex + 1 < yourString.Length )
        text = yourString.SubString( yourString.LastIndexOf( '>' ) + 1 );
      

  5.   

    这个是XPath支持的函数使用方法如下:
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <!-- suppress text nodes not covered in subsequent template rule -->
    <xsl:template match="text()"/><xsl:template match="region">
        <h3>Region "<xsl:value-of select="@name"/>" is in the 
            <xsl:choose>
                <xsl:when test="contains(@name, 'west')">
                    <xsl:value-of select="substring-before(@name, 'west')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="substring-before(@name, 'east')"/>
                </xsl:otherwise>
            </xsl:choose>
        </h3>
    </xsl:template></xsl:stylesheet>