2014-04-02 46 views

回答

1

在XSLT,可以添加一個頂層元素

<xsl:strip-space elements="*"/> 

通過使用以下的樣品輸入XML:

<?xml version="1.0" encoding="utf-8"?> 
<root> 
    <a>XXX</a> 
    <b>YYY</b> 
    <c>ZZZ</c> 
</root> 

和以下XSLT:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:strip-space elements="*"/> 

    <!-- this is called an identity template --> 
    <xsl:template match="node()|@*"> 
     <xsl:copy> 
      <xsl:apply-templates select="node()|@*"/> 
     </xsl:copy> 
    </xsl:template> 

</xsl:stylesheet> 

生產:

<?xml version="1.0" encoding="utf-8"?><root><a>XXX</a><b>YYY</b><c>ZZZ</c></root> 
+0

感謝您的回覆,您可以發送完整的xslt,我必須使用該要求。這將是非常有幫助 – Gablu

+0

我編輯了我的答案。這是一項任務嗎? –

+0

非常感謝:) – Gablu