我正在尝试将 XML 复制到相同的 XML
我正在使用以下 XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output indent="yes" method="xml"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
如果输入 XML 是:
<CatalogRequest>
<RequestFileHeader>
<ClientCode>340000</ClientCode>
<CreateTime>2012-04-11T14:57:03.357</CreateTime>
</RequestFileHeader>
</CatalogRequest>
我得到以下结果:
<?xml version="1.0" encoding="Windows-1252"?>
<ROOT>
<CatalogRequest>
<RequestFileHeader>
<ClientCode>340000</ClientCode>
<CreateTime>2012-04-11T14:57:03.357</CreateTime>
</RequestFileHeader>
</CatalogRequest>
</ROOT>
关于如何在不<ROOT>
添加节点的情况下保持相同 XML 的任何想法。
这被称为如下:
Dim Xct As New XslCompiledTransform
Xct.Load(New XmlTextReader(New StreamReader(xsltFileName)))
Dim xal As New XsltArgumentList
Dim helper As New XsltHelper
xal.AddExtensionObject("urn:XsltHelper", helper)
Dim memStream As New MemoryStream
Dim streamWriter As New StreamWriter(memStream, Text.Encoding.GetEncoding(1252))
Xct.Transform(doc, xal, streamWriter)