Downgrade XDocument e XmlReader per XmlDocument e XmlReader
-
19-09-2019 - |
Domanda
Voglio il downgrade di un Windows Mobile domanda fatta con .NET Compact Framework 3.5 a .NET Compact Framework 2.0 SP2 .
Ma ... non so come fare questo pezzo di codice compatibile con la versione 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())
{
...
}
Ho cambiato usando System.Xml.Linq con l'utilizzo di System.Xml, ma questa linea si lamenta:
using (System.Xml.XmlReader reader = doc.CreateReader())
Come posso ottenere un XmlReader da un XmlDocument?
Questo è il codice che ho declassato:
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())//;
{
...
}
Grazie!
Soluzione
Per creare un lettore di nodo:
using (XmlReader reader = new XmlNodeReader(doc.DocumentElement)) {...}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow