使用来自xml的msxml的属性值

时间:2010-04-09 15:30:53

标签: xslt

我有以下XML

<?xml version="1.0" encoding="ISO-8859-1" ?> 
- <DEVICEMESSAGES>
  <VERSION xml="1" checksum="" revision="0" envision="33050000" device="" /> 
  <HEADER id1="0001" id2="0001" content="Nasher[<messageid>]: <!payload>" /> 
  <MESSAGE level="7" parse="1" parsedefvalue="1" tableid="15" id1="24682" id2="24682" eventcategory="1003010000" content="Access to <webpage> was blocked due to its category (<info> by <hostname>)" /> 
  </DEVICEMESSAGES>

我正在使用以下xslt

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>

     <xsl:template match="DEVICEMESSAGES">
       <xsl:value-of select="@id2"/>,<xsl:text/>
       <xsl:value-of select="@content"/>,<xsl:text/>
       <xsl:text>&#xa;</xsl:text>
     </xsl:template>

</xsl:stylesheet>

当我使用MSXML时,我只是得到了,而我希望有类似

的东西
id2,             content
0001 ,           Nasher[<messageid>]: <!payload>" 

1 个答案:

答案 0 :(得分:0)

DEVICEMESSAGES元素根本没有属性

变化:

<xsl:template match="DEVICEMESSAGES"> 

为:

<xsl:template match="DEVICEMESSAGES/HEADER">