我有以下 VB.NET 代码,用于将一些 XML 转换为新的 XML,然后继续处理。这是一个一次性的过程,而不是多次完成的事情,所以据我所知,缓存没有效率。
该代码有效,但我看到了性能问题。我明白性能问题可能与 XSLT 有关。
我还发现开发人员遇到 XslCompiledTransform 性能问题的实例,尤其是在 64 位环境中,这可能是一个错误 ( http://connect.microsoft.com/VisualStudio/feedback/details/508748 )
可能的 XSLT 性能问题和 XslCompiledTransform 问题都不是我能控制的,但我的代码存在问题是可行的。我只是想确保我的转换方法是我需要的最有效的方法。
Public Function TransformUsingXPathNavigator(ByVal InputXML As XmlDocument, ByVal XSLTLocation As String) As XmlDocument
Dim theNavigator As XPathNavigator
theNavigator = InputXML.CreateNavigator()
Dim theTransform As XslCompiledTransform = New XslCompiledTransform()
theTransform.Load(XSLTLocation)
Dim outputXML As New XmlDocument()
Using writer As XmlWriter = outputXML.CreateNavigator().AppendChild()
theTransform.Transform(theNavigator, writer)
End Using
Return outputXML
End Function
有人能指出我的代码有任何问题吗?
编辑:这是一次性转换,所以没有循环。