1
<doc>
<elem attr="firstLine &x0a; secondLine"/>
<elem attr="1stLine"/>
</doc>
需要的是獲得的第一線,當有許多
從上面的例子中,我們希望得到{ 'firstLine中', '1stLine'}
在此先感謝
<doc>
<elem attr="firstLine &x0a; secondLine"/>
<elem attr="1stLine"/>
</doc>
需要的是獲得的第一線,當有許多
從上面的例子中,我們希望得到{ 'firstLine中', '1stLine'}
在此先感謝
使用:
substring-before(/*/elem[1]/@attr, '
')
下面是一個XSLT - 基於驗證:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="substring-before(/*/elem[1]/@attr, '
')"/>
</xsl:template>
</xsl:stylesheet>
當這個變換所提供的XML文檔施加(校正爲良好形成!!! ):
<doc>
<elem attr="firstLine 
 secondLine"/>
<elem attr="1stLine"/>
</doc>
它評估XPat H表達並輸出該評價的結果:
firstLine
如果你正在使用XPath 2.0,你可以使用tokenize()