我有以下VB.NET代码,用于将一些XML转换为新的XML,然后继续处理。这是一次性过程,不是多次执行,因此我认为从缓存中获得效率并没有优化的空间。
代码可以工作,但我遇到了性能问题。 我知道性能问题可能与XSLT有关。
我还发现开发人员在64位环境下使用XslCompiledTransform时出现性能问题,这可能是一个错误(http://connect.microsoft.com/VisualStudio/feedback/details/508748)。
可能存在XSLT性能问题或XslCompiledTransform问题,这两个问题都不在我的控制范围内,但我的代码可能存在问题。我只是想确保我的转换方法对我所需的最有效。
代码可以工作,但我遇到了性能问题。 我知道性能问题可能与XSLT有关。
我还发现开发人员在64位环境下使用XslCompiledTransform时出现性能问题,这可能是一个错误(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
有人能指出我的代码存在的问题吗?
编辑:这是一次性转换,所以没有循环。
XslCompiledTransform
对象,并将其传递到XSLTLocation
的位置。Load()
方法运行的次数越少,效果越好。 - psmay