<ValueComponentIntervals>
<ValueComponentInterval Id="13095" >
<RelateId>11840</RelateId>
<RelateClass>cPriceQuoteInterval</RelateClass>
<SourceId>11225</SourceId>
<SourceClass>cHDProduct</SourceClass>
<ParentId>11225</ParentId>
<ParentClass>cHDProduct</ParentClass>
<IntervalCount>20,170,601</IntervalCount>
<ValueNum>50,000</ValueNum>
<UnitOfMeasureCode>KH</UnitOfMeasureCode>
<TimeStamp NativeString="20160215162241399" UTCOffset="-300" >02/15/2016 04:22:41 PM</TimeStamp>
<IntervalGroupCode>USG</IntervalGroupCode>
<TypeCode>ACT</TypeCode>
<DescriptionInfo>JUNE</DescriptionInfo>
<VCITypeDescription>Actual VCI</VCITypeDescription>
<Name>Usage</Name>
</ValueComponentInterval>
<ValueComponentInterval Id="13096" >
<RelateId>11840</RelateId>
<RelateClass>cPriceQuoteInterval</RelateClass>
<SourceId>11225</SourceId>
<SourceClass>cHDProduct</SourceClass>
<ParentId>11225</ParentId>
<ParentClass>cHDProduct</ParentClass>
<IntervalCount>20,170,601</IntervalCount>
<ValueNum>0.0999</ValueNum>
<UnitOfMeasureCode>USD</UnitOfMeasureCode>
<TimeStamp NativeString="20160215162241399" UTCOffset="-300" >02/15/2016 04:22:41 PM</TimeStamp>
<IntervalGroupCode>GEN</IntervalGroupCode>
<TypeCode>ACT</TypeCode>
<DescriptionInfo>Fixed Price</DescriptionInfo>
<VCITypeDescription>Actual VCI</VCITypeDescription>
<Name>Price</Name>
</ValueComponentInterval>
</ValueComponentIntervals>
我尝试使用XSL模板(见下文)从上面的XML块渲染表格,但它不起作用。
<xsl:for-each select="ValueComponentIntervals/ValueComponentInterval[Name = 'Usage']">
<xsl:valueof select="ValueNum">
<p>
<span style="background-color:yellow; font-family:Arial; font-size:small">
<xsl:apply-templates/>
</span>
</p>
</xsl:valueof>
</xsl:for-each>
Id
不一致,因为它们是由软件包自动生成的,TimeStamp Nativestrings也是如此。我对XSLT / XML有点新意,我被卡住了......
更新
我有不同数量的ValueComponentInterval块。我正在尝试选择名称仅为&#34; USAGE&#34;并返回&#34; VALUENUM&#34;。
下的值答案 0 :(得分:1)
我调整了这个版本并且非常确定这是您尝试完成的(与名为root
的假设根节点相关,其中ValueComponentIntervals
是一个孩子):
<xsl:template match="/root">
<xsl:for-each select="ValueComponentIntervals/ValueComponentInterval[Name = 'Usage']">
<xsl:element name="p">
<xsl:element name="span">
<xsl:attribute name="style">background-color:yellow; font-family:Arial; font-size:small</xsl:attribute>
<xsl:value-of select="ValueNum" />
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>
结果是
<?xml version="1.0" encoding="UTF-8"?>
<p>
<span style="background-color:yellow; font-family:Arial; font-size:small">50,000</span>
</p>
编辑:在你的情况下,这可能会更好。