Extracting some data from XML
<block1>
<tag>
<name>59</name>
<value>/00940001812410930828 FONDITEL VALORES AV SAU ATAM PEDRO TEIXERIA 8 PLANTA 7A 28020MADRID
</value>
开发者_C百科</tag>
</block1>
I need the output as 00940001812410930828 ,FONDITEL VALORES AV SAU ATAM PEDRO TEIXERIA 8 PLANTA 7A 28020MADRID
Can any one help me please?
If I'm not missing anything try the following approach:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//value">
<xsl:value-of select="substring-after('/', normalize-space(.))"/>
</xsl:template>
</xsl:stylesheet>
In case you want to concentrate on string processing you should probably consider improving your xml markup instead of that. Otherwise working with string values with xslt 1.0 is tedious. (if you're using 2.0 then there is a list of predefined functions exactly for this purpose (like fn:tokenize).
This XPath expression:
concat(
substring-after(
substring-before(
/block1/tag/value,
' '
),
'/'
),
' ,',
substring-after(
/block1/tag/value,
' '
)
)
Or this XSLT stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="value">
<xsl:value-of select="substring-after(
substring-before(
/block1/tag/value,
' '
),
'/'
)"/>
<xsl:text> ,</xsl:text>
<xsl:value-of select="substring-after(
/block1/tag/value,
' '
)"/>
</xsl:template>
</xsl:stylesheet>
And a simple XPath 2.0 expression:
replace(/block1/tag/value,'/([^ ]* )(.*)','$1,$2')
精彩评论