473,508 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlDocument: "connection was closed" exception reading local file???

Hello

I want to load a local file into the XmlDocument cache. But when I'm not
connected to the internet I get this exeption: "The underlying connection
was closed: The remote name could not be solved."
Has anyone an idea how I can avoid this exception?

Thank you
Sincerely Lore

*********** method:
private static XmlNamespaceManager namespaceManager;
public static XmlDocument GetParagraphsDoc(string file, ComboBox comboBox1)
{
XmlDocument doc = null;
try {
XmlTextReader reader = new XmlTextReader(file);
doc = new XmlDocument();
doc.Load(reader); //exception thrown
reader.Close();

namespaceManager = new XmlNamespaceManager(doc.NameTable);
namespaceManager.AddNamespace("xl", "http://www.w3.org/1999/xhtml");
XmlNodeList nodeList = doc.SelectNodes("//xl:p[@ class='paragraph']",
namespaceManager);
// Iterate on the node set
int nr = 0;
comboBox1.Items.Clear();
foreach (XmlNode node in nodeList)
{
comboBox1.Items.Add("Eintrag " + node.InnerText);
}
}
catch(Exception ex) { Console.WriteLine(ex.Message); }
return doc;
}

*********** xml-Document:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id='content'>
<p class='paragraph'>
<img src='' alt='' />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum
convallis, risus vel sodales fermentum, purus nisi consectetuer sem,
fringilla viverra purus dui vel pede. Maecenas nisl dui, semper eget,
feugiat at, varius eget, justo.
</p>
<p class='paragraph'>
<img src='' alt='' />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum
convallis, risus vel sodales fermentum, purus nisi consectetuer sem,
fringilla viverra purus dui vel pede. Maecenas nisl dui, semper eget,
feugiat at, varius eget, justo.
</p>
<p style='text-align:center'>°</p>
</div>
</body>
</html>
Apr 16 '06 #1
1 2136


Lore Leunoeg wrote:
I want to load a local file into the XmlDocument cache. But when I'm not
connected to the internet I get this exeption: "The underlying connection
was closed: The remote name could not be solved."
Has anyone an idea how I can avoid this exception? XmlTextReader reader = new XmlTextReader(file);
doc = new XmlDocument();
doc.Load(reader); //exception thrown *********** xml-Document:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


The parser will try to load the referenced URL of the DTD, you can set
the XmlResolver property of the XmlDocument (or in your case of the
XmlTextReader) to make sure the request goes to a local copy of the DTD
you keep around.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2152
by: David Cho | last post by:
Hi, this is just plain strange. This is my code. HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://www.yahoo.com"); request.Method = "POST"; request.ContentType =...
1
3204
by: Sean Nolan | last post by:
We have implemented unhandled error trapping at the application level and log these errors to our database. One error, however, the does not get trapped is when the connection pool has exceeded the...
0
18436
by: BGS | last post by:
I have a web site (www.on-the-matrix.com) that displays photos in a "slide show" format on ASPX pages that run in an inline frame on an ASP page (or in a separate pop-up window). The ASPX pages...
0
2590
by: lpinho | last post by:
Hi There, I've generated a C# file from a wsdl file using wsdl.exe utility. Then I created a console application and made a call to the method generated, first I got the error: "The request...
0
6033
by: Ashish | last post by:
I am using the following code and i am getting the following error :- "Cannot access a closed file." while reading the content of the InputStream. Microsoft suggestes that one should not release...
7
10521
by: STUPIDFORUM | last post by:
ADODB.Recordset "The connection cannot be used to perform this operation." "Microsoft Access Driver" ERROR 0X800A0E7D OLE exception from "ADODB.Recordset": The connection cannot be used to...
1
206
by: Sin Jeong-hun | last post by:
Some of my clients (but I don't) get the "The underlying connection was closed" exception. According to this article (http://...
2
3137
by: kkshansid | last post by:
i am from asp background i am very new to asp.net environment i want to know that is there any include in asp.net as in asp so that i can include connection file which is asp.net and asp files ...
1
2405
by: Gx3r0 | last post by:
0I have a windows service I created that checks for data to post to an off site webservice over SSL. The service checks every 10 seconds for data to send, if there is data it opens a connection to...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.