Reduce XDocument and XmlReader to XmlDocument and XmlReader

I want to downgrade a Windows Mobile application made from .Net Compact Framework 3.5 to .Net Compact Framework 2.0 SP2 .

But ... I do not know how to make this piece of code compatible with version 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())
{
     ...
}

I changed the use of System.Xml.Linq using System.Xml, but this line complains:

using (System.Xml.XmlReader reader = doc.CreateReader())

How can I get an XmlReader from an XmlDocument?

This is the code I downgraded:

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())//;
{
    ...
}

Thanks!

+3
source share
1 answer

To create a node reader:

using (XmlReader reader = new XmlNodeReader(doc.DocumentElement)) {...}
+5
source

Source: https://habr.com/ru/post/1722601/


All Articles