Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error reading XML file in C#

Posted on 2009-06-30
3
Medium Priority
?
886 Views
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?


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

0
Comment
Question by:pharpe
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
mohan_sekar earned 2000 total points
ID: 24745135
0
 
LVL 15

Assisted Solution

by:mohan_sekar
mohan_sekar earned 2000 total points
ID: 24745137
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

972 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