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>