Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 当我们没有';我不知道他们的名字_Xslt_Xpath - Fatal编程技术网

Xslt 当我们没有';我不知道他们的名字

Xslt 当我们没有';我不知道他们的名字,xslt,xpath,Xslt,Xpath,我必须处理不知道节点名称的XML文件。我只知道不同文件之间的结构是相同的 结构将如上所述 <root> <node1> <node2> </node2> </node2> </root> 我必须创建一个XSLT文件来构建一个HTML页面,该页面将显示节点的内容 现在我有了这段代码 <xsl:template match="/"> <html>

我必须处理不知道节点名称的XML文件。我只知道不同文件之间的结构是相同的

结构将如上所述

<root>
    <node1>
        <node2>
        </node2>
    </node2>
</root>

我必须创建一个XSLT文件来构建一个HTML页面,该页面将显示节点的内容

现在我有了这段代码

<xsl:template match="/">
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="employe.css"/>
  </head>
  <body>
    <table>
      <tr>
        <th>ID Source</th>
        <th>Nom</th>
        <th>Prénom</th>
        <th>Age</th>
        <th>Adresse</th>
        <th>Code Postal</th>
        <th>Ville</th>
        <th>Telephone</th>
        <th>Poste</th>
      </tr>
      <xsl:apply-templates/>
    </table>
  </body>
</html>
</xsl:template>

<xsl:template match="child::*">
    <tr>
        <xsl:apply-templates/>
    </tr>
</xsl:template>

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

ID源
笔名
名词
年龄
阿迪斯
邮政编码
维尔
电话
邮政
我成功地选择了第一级和第二级节点,但不知道如何选择第三级节点


感谢您的帮助,您可以尝试将
match=“/”
更改为
match=“/*”
,并添加以下两个模板:

<xsl:template match="*[*]">
    <tr>
        <xsl:apply-templates/>
    </tr>
</xsl:template>

<xsl:template match="*[not(*)]">
    <td><xsl:value-of select="."/></td>
</xsl:template>


谢谢你的回答,但是。。。你能解释一下吗?我从XLST/XPath开始,并不真正理解您的建议。匹配
/*
将匹配
。第一个模板(
*[*]
)将元素与子元素匹配。第二个模板(
*[not(*)]
)匹配没有子元素的元素。如果有帮助,我可以附上一个完整的例子。不,谢谢,完美的解释!;)不过,如果我将match=“/”更改为match=“/*”,它将不起作用,因为没有创建表应答器