C# XSLT可以';无法获取xml子元素

C# XSLT可以';无法获取xml子元素,c#,xml,xslt,C#,Xml,Xslt,我有以下xsl样式表和xml,但我无法在xsl模板匹配中获取xml父节点中的元素不起作用,我无法从xml获取表和客户节点 <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:templat

我有以下xsl样式表和xml,但我无法在xsl模板匹配中获取xml父节点中的元素不起作用,我无法从xml获取表和客户节点

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>

    <xsl:template match="/">
        <HTML>
            <HEAD>
                <TITLE>Title</TITLE>
            </HEAD>
            <BODY>
                <xsl:apply-templates/>
            </BODY>
        </HTML>
    </xsl:template>

    <xsl:template match="/parent"> 
        <xsl:apply-templates/> 
    </xsl:template>

    <xsl:template match="costumer">
        <p>Costumer</p>
    </xsl:template>

    <xsl:template match="table">
        <xsl:variable name="name" select="@name"/>
        <xsl:variable name="type" select="@type"/>
        <xsl:variable name="height" select="@height"/>
        <xsl:variable name="width" select="@wdth"/>
        <xsl:variable name="margin-top" select="@margin-top"/>
        <xsl:variable name="margin-left" select="@margin-left"/>
        <table id="{$name}" width="{$width}" height="{$height}" style="margin-top:{$margin-top}; margin-left:{$margin-left}">
            <thead>
                <tr>
                    <xsl:apply-templates select="*[1]/*" mode="th"/>
                </tr>
            </thead>
            <tbody>
                <xsl:apply-templates select="*"/>
            </tbody>
        </table>
    </xsl:template>

    <xsl:template match="/*/*/*" mode="th">
        <th>
            <xsl:value-of select="*"/>
        </th>
    </xsl:template>

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

    <xsl:template match="/*/*/*">
        <xsl:variable name="texttd" select="@text"/>
        <td>
            <xsl:value-of select="$texttd"/>
        </td>
    </xsl:template>
</xsl:stylesheet>

标题
顾客

下面是xml文件

<?xml version="1.0" encoding="utf-8"?>
<parent>
    <table name="region1" type="td" wdth="0" height="0" margin-top="1" margin-left="122">
        <td margin-top="0" margin-left="152" width="36" height="13" font-family="Arial-BoldMT" font-size="16" font-weight="0" text="??&quot;?" line-height="300" is-visible="True" color="#0A4462" />
        <Text name="region1" type="Title" wdth="0" height="0" margin-top="7" margin-left="138">
            <Title margin-top="0" margin-left="14" width="36" height="13" font-family="Arial-BoldMT" font-size="16" font-weight="0" text="??&quot;?" line-height="300" is-visible="True" color="#0A4462" />
        </Text>
    </table>
    <table name="region1" type="td" wdth="0" height="0" margin-top="1" margin-left="122">
        <td margin-top="0" margin-left="152" width="36" height="13" font-family="Arial-BoldMT" font-size="16" font-weight="0" text="??&quot;?" line-height="300" is-visible="True" color="#0A4462" />
        <Text name="region1" type="Title" wdth="0" height="0" margin-top="7" margin-left="138">
            <Title margin-top="0" margin-left="14" width="36" height="13" font-family="Arial-BoldMT" font-size="16" font-weight="0" text="??&quot;?" line-height="300" is-visible="True" color="#0A4462" />
        </Text>
    </table>
    <table name="region1" type="td" wdth="0" height="0" margin-top="1" margin-left="122">
        <td margin-top="0" margin-left="152" width="36" height="13" font-family="Arial-BoldMT" font-size="16" font-weight="0" text="??&quot;?" line-height="300" is-visible="True" color="#0A4462" />
        <Text name="region1" type="Title" wdth="0" height="0" margin-top="7" margin-left="138">
            <Title margin-top="0" margin-left="14" width="36" height="13" font-family="Arial-BoldMT" font-size="16" font-weight="0" text="??&quot;?" line-height="300" is-visible="True" color="#0A4462" />
        </Text>
    </table>
    <costumer></costumer>
    <costumer></costumer>
</parent>

这样的通用模板具有更高的优先级。表达式中的斜杠数似乎与优先级有关

我认为应该通过使XPath更具体来提高所需模板的优先级

<xsl:template match="/parent/table">
<xsl:template match="/parent/costumer">
作为替代方案,您可以明确增加所需项目的优先级:

<xsl:template match="table" priority="5">

除此之外,我还需要完整的预期输出,以查看这是否有助于构建您正在寻找的解决方案


顺便说一句:我想你想要的是客户而不是客户。

你的样式表末尾有
吗?你有没有收到错误?你想得到什么?你得到了什么?我没有得到一个错误,我只是得到没有表格的html,所以我想有

,但不是那样,我只得到td中的文本,比如text1td text2td text3t,我忘了把它放进去here@Arthur如果你认为这是有帮助的,您可以通过单击大数字旁边的
^
图标向上投票。如果您将此视为已接受的答案,您可以单击该数字以下的复选标记。它将帮助其他人专注于未回答的问题。你和我这样做都会赢得声誉。非常感谢。
<xsl:template match="table" priority="5">