如何从输出xml中删除命名空间?

前端之家收集整理的这篇文章主要介绍了如何从输出xml中删除命名空间?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
以下是我的xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:ms="http://www.test.com/schemas/test" 
xmlns:ns="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms ns">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<XMLResponse>           
    <xsl:apply-templates select="ms:ProductRS/ms:Product"/>
</XMLResponse>
</xsl:template>
<-- some templates here -->
</xsl:stylesheet>

输出我喜欢下面

<?xml version="1.0" encoding="UTF-16"?>
<XMLResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Product>-----</Product>
</XMLResponse>

我需要从xml输出删除xmlns:xsi =“http://www.w3.org/2001/XMLSchema-instance”

要排除一个命名空间,那么你应该这样表示:

exclude-result-prefixes =“ms ns xsi”

基本上你的样式表如下所示:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:ms="http://www.test.com/schemas/test" 
xmlns:ns="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms ns xsi">
原文链接:https://www.f2er.com/xml/292849.html

猜你在找的XML相关文章