0

我是 xsl 的初学者,遇到格式化节点(即 UnitCost)值的问题。

我想要节点 UnitCost 值,即;5.0000(小数点后 4 个零)到使用 xsl 小数点后仅 2 个零。

xml文件:

  <root>
        <item>
        <link>http://localhost/Store/tabid/62/ProdID/1/Default.aspx</link>
        <P>
        <NB_Store_ProductsInfo>
        <ProductID>1</ProductID>
        <PortalID>0</PortalID>
        <TaxCategoryID>-1</TaxCategoryID>
        <Featured>false</Featured>
        <Archived>false</Archived>
        <CreatedByUser>1</CreatedByUser>
        <CreatedDate>2010-07-10T05:04:40.233</CreatedDate>
        <IsDeleted>false</IsDeleted>
        <ProductRef />
        <Lang>en-US</Lang>
        <Summary />
        <Description>sdcvsdcsdc&amp;lt;br /&amp;gt;
        dcsdcsdcsdcsdcsdcsdcs</Description>
        <Manufacturer />
        <ProductName>Poster1</ProductName>
        <XMLData />
        <ModifiedDate>2010-07-10T05:25:48.077</ModifiedDate>
        <SEOName />
        </NB_Store_ProductsInfo>
        <M>
        <NB_Store_ModelInfo>
        <ModelID>1</ModelID>
        <ProductID>1</ProductID>
        <ListOrder>1</ListOrder>
        <UnitCost>5.0000</UnitCost>
        <Barcode/>
....

从 xml 文件中读取 UnitCost

<xsl:value-of select="./P/M/NB_Store_ModelInfo/UnitCost" />

任何帮助都是有帮助的..

4

1 回答 1

2

尝试使用该format-number()功能:

<xsl:value-of select="format-number(./P/M/NB_Store_ModelInfo/UnitCost, '#.00')" />
于 2013-04-06T06:10:27.467 回答