Link to home
Start Free TrialLog in
Avatar of jssong2000
jssong2000

asked on

How to read an unknown xml file in C#

I am new in XML.
I want to read a xml file from directory C:\incoming\myproject. The xml file coould be any name. Any help or comments will be very appreciated!!!
Avatar of ericwong27
ericwong27
Flag of Singapore image

Try on following

foreach (var item in Directory.GetFiles(@"C:\incoming\myproject","*.XML"))
 {
       ReadXMLFile(item.ToString());
 }
Avatar of jssong2000
jssong2000

ASKER

I got an error using ReadXMLFile, what I need to do? Thank you!
ASKER CERTIFIED SOLUTION
Avatar of ericwong27
ericwong27
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also do the following:

DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/App_Data/MyXMLFile.xml"));

Open in new window

It worked. Thank you!!!