Error reading XML file in C#

Posted on 2009-06-30
Last Modified: 2012-05-07
I am trying to read an XML file into a dataset in C#.  I am using newDataSet.ReadXml(path+file) to read the xml file but I get this error:

System.IO.FileNotFoundException: Could not find file '\\<path>\importer.dtd'

I know the cause of the error.  It is this line in the xml header:

<!DOCTYPE importFile SYSTEM "importer.dtd">

If I remove that line everything works fine.  The problem is that I do not have control of how the xml is created and have to deal with what is passed to me.  Is there any way I can ignore this line or otherwise handle this in a way that allows me to bring in the data?

// create a new DataSet.
        DataSet newDataSet = new DataSet("New DataSet");
            // read the XML document into the DataSet.
        catch (Exception e1)
            AppendLog(Server.MapPath(".") + "\\log\\settlepricelog.txt", "Price file not found.  Details below");
            AppendLog(Server.MapPath(".") + "\\log\\settlepricelog.txt", e1.ToString());
            throw (e1); 
Here is the xml header and the first line of data:
<?xml version="1.0"?>
<!DOCTYPE importFile SYSTEM "importer.dtd">
<importFile template="default" dateFmt="DDMMMYY">
<priceImport type = 'DAILY' ><pset>SETTLEMENT</pset><market>GDAILY</market><maturity>0CAL</maturity><settle>F</settle><pformat>*</pformat><date>21Jun09</date><comp>AECOC</comp><price>3.1300</price></priceImport>

Open in new window

Question by:pharpe
  • 2
LVL 15

Accepted Solution

mohan_sekar earned 500 total points
ID: 24745135
LVL 15

Assisted Solution

mohan_sekar earned 500 total points
ID: 24745137

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question