Xml 如何删除具有值的标签 

Xml 如何删除具有值的标签&#160;,xml,xslt,tags,space,Xml,Xslt,Tags,Space,输入为: <p>&#160;</p> 我的xslt代码是: <xsl:variable name='list' select='//div'/> <xsl:template match='/'> <xsl:for-each select='$list'> <xsl:element name='section'> <xsl:apply-

输入为:

<p>&#160;</p>
我的xslt代码是:

<xsl:variable name='list' select='//div'/>

<xsl:template match='/'>

        <xsl:for-each select='$list'>
            <xsl:element name='section'>
                <xsl:apply-templates select='*[not(name(.)="div")]'/>

            </xsl:element>
        </xsl:for-each>

</xsl:template>

输出为:

 <section>
        <title>Operational Commands</title>
        <p>show ip nat filtershow ip nat interfaceshow ip nat interface-statistics</p>
    </section><section>
        <title>Release Information</title>
        <p>Command introduced in Viptela Software Release 18.3.​</p>
    </section><section>
        <title>Additional Information</title>
        <p>See the Configuring Transport-Side NAT article for your software release.</p>
        <p> </p>
    </section>

作战指挥
显示ip nat筛选器显示ip nat接口显示ip nat接口统计信息

发布信息 Viptela软件版本18.3中引入的命令。​

补充资料 有关您的软件版本,请参阅配置传输端NAT一文


在最后一节中,
标记有被视为空标记的空间,那么我需要删除这个空标记。如何删除此项?

首先,包含不间断空格的元素不是空的。除非您指示样式表将其转换,否则输出中的非中断空格不会“转换为空格”

现在,要删除
 

element,您可以添加与之匹配的空模板:

<xsl:template match="p[.='&#160;']"/>

这里的输入是:ASCII格式的nbsp

i。e ;如果您有任何现有的XSLT将非中断空间“转换”为正常空间,那么您应该向我们展示该代码。现在还不清楚您是想修复某些特定的XSLT代码,还是想编写XSLT来删除任何
 

来自任何输入的元素。我已经在下面编写了我的代码。请编辑您的问题以提供任何详细信息,而不是作为答案。还考虑向我们展示最小但完整的样本和信息,以允许我们重现问题。您在“答案”中显示的XSLT部分根本不会创建任何
p
元素。它也不会将像不间断空格这样的字符转换为空格。好吧……那么我需要做什么来删除空的标记呢?很好。如果您的问题得到了回答,请通过接受答案来结束它。我不知道您的意思。实际上,我想删除xml中存在的所有空标记。我的xml 1中有两种情况 和#160

二,。当我申请删除所有空元素时,您可以使用
。要删除一些空元素,可以使用
 <section>
        <title>Operational Commands</title>
        <p>show ip nat filtershow ip nat interfaceshow ip nat interface-statistics</p>
    </section><section>
        <title>Release Information</title>
        <p>Command introduced in Viptela Software Release 18.3.​</p>
    </section><section>
        <title>Additional Information</title>
        <p>See the Configuring Transport-Side NAT article for your software release.</p>
        <p> </p>
    </section>
<xsl:template match="p[.='&#160;']"/>
<xsl:template match="p[not(normalize-space(translate(., '&#160;', ' ')))]"/>