Load XML file and extract elements in C#

session101

Member
Joined
May 10, 2006
Messages
23
I created a config with the location of my xml file:
<add key="positionXML" value = "C:temp\PositionMsg.xml" />

When I try to load the xml file into my C# code, I am doing the following:
XmlDocument objDoc=new XmlDocument();
objDoc.LoadXml(ConfigurationSettings.AppSettings["positionXML"]);


What should I do to load the XML file and get the data elements in the XML? TIA.
 
Last edited by a moderator:
load not loadxml

loadxml uses a string of xml to load the document. what you want is a stream. use xmldocument.load(stream) - create a filestream using the path and then call load.
 
Back
Top