Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading an XML Feed into XElement

I have an Xml Stream that I'd like to read into an XElement. I've seen samples that use XmlTextReader but I need it in an XElement.

The code that I have so far:

string url = 
 String.Format( "http://dev.virtualearth.net/REST/v1/Locations/{0}?o=xml&key={1}", HttpUtility.UrlEncode( AddressQuery ), mapkey );

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;  

XmlTextReader reader = new XmlTextReader( url );

I'm just not sure how to get the reader into an XElement. Perhaps I'm going about it the wrong way.

like image 465
Armstrongest Avatar asked Dec 16 '22 13:12

Armstrongest


1 Answers

with linq to xml you can simply do this

var xml = XElement.Load(uri);
like image 133
NinjaNye Avatar answered Jan 04 '23 09:01

NinjaNye