How can I read a field from an Xml stream without deserializing it?
XPath can do the job.. This is an example where we read the town name (Xml element) )and the state attribute from the Xml file: XmlDocument document = new XmlDocument(); document.Load(“town.xml”); //Select an element string _TownName = document.SelectSingleNode(“//city/townname”).InnerText; //Select an attribute string _State = document.SelectSingleNode(“//city”).Attributes[“state”].InnerText; MessageBox.Show(_TownName + ” is in ” + _State); This is an example where we read an application setting from a web config file. XmlDocument configDocument = new XmlDocument(); configDocument.Load(“web.config”); // Add the namespace with .Net web.config XmlNamespaceManager nsmgr = new XmlNamespaceManager(configDocument.NameTable); nsmgr.AddNamespace(“ms”, “http://schemas.microsoft.com/.NetConfiguration/v2.0”); string appSetting = configDocument.SelectSingleNode( “/ms:configuration/ms:appSettings/ms:add[@key=’DatabaseName’]”, nsmgr).Attributes[“value”].InnerText; The orignal config file: