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+fi le) to read the xml file but I get this error:
System.IO.FileNotFoundExce ption: 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?
System.IO.FileNotFoundExce
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.