Link to home
Start Free TrialLog in
Avatar of pharpe
pharpe

asked on

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?


code:
// create a new DataSet.
        DataSet newDataSet = new DataSet("New DataSet");
 
        try
        {
            // read the XML document into the DataSet.
            newDataSet.ReadXml(path+file);
        }
        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

ASKER CERTIFIED SOLUTION
Avatar of mohan_sekar
mohan_sekar
Flag of United States of America 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
SOLUTION
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