XML,XSL,如何将子节点从xml文件提取到xsl文件

时间:2021-04-13 15:40:07

i have an xml file that looks like this :

我有一个看起来像这样的xml文件:

<TestRun>
 <FailedTests>
  <FailedTest id="19">
   <Name>Test</Name>
   <FailureType>Assertion</FailureType>
   <Location>
     <File>Sets.cpp</File>
   </Location>
   <Details>
     <Detail id="1">Exception caught returning cmd response </Detail>
     <Detail id="2">unresolvable error code</Detail>
   </Details>
  </FailedTest>
 </FailedTests>
</TestRun>

and i want to get the value of child nodes of TestRun/FailedTests/FailedTest/Details, how can i do this?? i tried this but it doesnt work :

我想获得TestRun / FailedTests / FailedTest / Details的子节点的值,我该怎么做?我试过这个,但它不起作用:

        <TD>
            <xsl:for-each select="Details/Detail">
               <br></br><br></br>
            <xsl:value-of select="(Detail)"/>
            </xsl:for-each>
        </TD>
    </TR>

1 个解决方案

#1


1  

When you're inside the Details/Detail for-each you can print the content of the current element by doing:

当您在详细信息/详细信息中时,您可以通过执行以下操作来打印当前元素的内容:

<xsl:value-of select="."/>

#1


1  

When you're inside the Details/Detail for-each you can print the content of the current element by doing:

当您在详细信息/详细信息中时,您可以通过执行以下操作来打印当前元素的内容:

<xsl:value-of select="."/>