Read an XML file from http address Read an XML file from http address xml xml

Read an XML file from http address


You'll want to use LINQ to XML to process the XML file. The XDocument.Load Method supports loading an XML document from an URI:

var document = XDocument.Load("https://10.1.12.15/xmldata?item=all");


Another way to do this is using the XmlDocument class. A lot of servers around the world are still running .Net Framework < 3.0 so it's good to know that this class still exists alongside XDocumentin case you're developing an application that will be run on a server.

string url = @"https://10.1.12.15/xmldata?item=all";XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(url);


Maybe the correct answer must starting by reading the initial question about how to "Read an XML file from a URL (or in this case from a Http address)".

I think that can be the best for you see the next easy demos:

(In this case XmlTextReader but today you can use XmlReader instead of XmlTextReader)http://support.microsoft.com/en-us/kb/307643

(Parallel you could read this documentation too).https://msdn.microsoft.com/en-us/library/system.xml.xmlreader(v=vs.110).aspx

regards