asp.net – 替换过时的System.Xml.XmlDataDocument?

前端之家收集整理的这篇文章主要介绍了asp.net – 替换过时的System.Xml.XmlDataDocument?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经从.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";

希望它有帮助.

原文链接:https://www.f2er.com/aspnet/250427.html

猜你在找的asp.Net相关文章