• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 945
  • Last Modified:

Error reading XML file in C#

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

  • 2
2 Solutions
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now