开发者

Find and replace with incremental number at the end

I have an xml file with multiple nodes:

<member>开发者_运维技巧;
    <screen_name>User</screen_name>
    <username>username</username>
</member>

What I want tis to find an replace User with User1,User2,User(n) and username with username1,username2, username(n)

Is that possible?


Apply this XSL template to your XML files (there are several command line tools that can do this)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*" />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="screen_name/text() | username/text()">
    <xsl:value-of select="concat(., count(preceding::member) + 1)" />
  </xsl:template>
</xsl:stylesheet>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜