2

I have IDs that are coming through in XML files that are padded with zeros, such as:

<dog pet_id="00005">

When parsing this, I'd like to just get the integer 5. Doing something like:

<xsl:value-of select="dog/@pet_id" />

retrieves "00005"

What's the best way to do this to just get 5?

4

1 回答 1

5

你可以试试:

<xsl:value-of select="number(dog/@pet_id)" />

或者如果您需要转换回字符串:

<xsl:value-of select="string(number(dog/@pet_id))" />
于 2013-08-19T22:32:34.907 回答