降级XDocument和XmlReader到XmlDocument和XmlReader
作者:互联网
我想将使用.Net Compact Framework 3.5制作的Windows Mobile应用程序降级为.Net Compact Framework 2.0 SP2.
但是…我不知道如何使这段代码与2.0版兼容.
XDocument doc = XDocument.Load(string.Format(Open_Cell_Id_Uri, new object[]{
Settings.OpenCellIDApiKey,
towerDetails.MobileCountryCode,
towerDetails.MobileNetworkCode,
towerDetails.TowerId,
towerDetails.LocationAreaCode
}));
using (System.Xml.XmlReader reader = doc.CreateReader())
{
...
}
我使用System.Xml和System.Xml.Linq进行了更改,但是此行在抱怨:
using (System.Xml.XmlReader reader = doc.CreateReader())
如何从XmlDocument获取XmlReader?
这是我降级的代码:
XmlDocument doc = new XmlDocument();
doc.Load(string.Format(Open_Cell_Id_Uri, new object[]{
Settings.OpenCellIDApiKey,
towerDetails.MobileCountryCode,
towerDetails.MobileNetworkCode,
towerDetails.TowerId,
towerDetails.LocationAreaCode
}));
using (System.Xml.XmlReader reader = doc.CreateReader())//;
{
...
}
谢谢!
解决方法:
要创建节点读取器:
using (XmlReader reader = new XmlNodeReader(doc.DocumentElement)) {...}
标签:linq-to-xml,compact-framework,downgrade,c 来源: https://codeday.me/bug/20191024/1919778.html