Generally, this is how I deserialize an XML file:
string location = "C:\\test.xml";
XmlObjectClass member_data = new XmlObjectClass();
using (Stream XmlStream = new FileStream(location,FileMode.Open))
{
data = (XmlObjectClass)serializer.Deserialize(XmlStream);
}
This works when I’m desrializing an XML file, but what if I want to deserialize an XML that is returned by a web request (i.e. going to a URL)?
Well, there are a few options:
XmlReaderwithXmlReader.Create(uri)and deserialize directlyWebClientorHttpWebRequest, and deserialize from the streamMemoryStreamand deserialize from thatIf you don’t need to do anything special with the web request – i.e. it’s really just a “GET” from a URI – then the first option is probably the simplest.