我已经从.NET 2.0升级到.NET 4.0的Webforms应用程序中有一个System.Web.UI.WebControls.Xml控件(Xml1)
... Dim ds As DataSet = app.GetObjects Dim xmlDoc As New System.Xml.XmlDataDocument(ds) Xml1.Document = xmlDoc Xml1.TransformSource = "~/xslt/admin_objectslist.xslt" ...
从第二行我得到警告:
‘System.Xml.XmlDataDocument’ is obsolete: ‘XmlDataDocument class will be removed in a future release.’.
从第三行我得到警告:
‘Public Property Document As System.Xml.XmlDocument’ is obsolete: ‘The recommended alternative is the XPathNavigator property. Create a System.Xml.XPath.XPathDocument and call CreateNavigator() to create an XPathNavigator.
为什么推荐使用.NET 4.0替代?
解决方法
d.我也遇到了这个问题,3.5.这是我想出来的:
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(ds.GetXml()); xml1.XPathNavigator = xmlDoc.CreateNavigator(); xml1.TransformSource = @"~/XSLT/LogEntryTransform.xslt";
希望它有帮助.