------- I have also posted this to the microsoft.public.xml group but I
am not sure which one it belongs in ------
OK - I have an XML file from a vendor that uses a DTD files as follows:
<!DOCTYPE metis PUBLIC "-//METIS/METIS XML 1.2//EN"
"http://xml.metis.no/metis12.dtd">
The problem is - currently and periodically - the vendor takes the dtd
file offline. Thus, when I am trying to open the XML document in
Vb.Net using the following code:
Private iobj_MetisModel As New XmlDocument
iobj_MetisModel.Load(is_Path_To_Metis_File)
The load is failing with a SocketException because the DTD is not
available (see full stack trace below). I am only reading the XML and
doing some Xpath queries on it. Any idea how I can tell the XML
document to simply continue if it cannot access the DTD?
-------------------------------- Stack Trace
-----------------------------------
MetisReporting: An error occurred while the Metis Reporting System
process was running. Full details are below. System.Net.WebException:
Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because
the connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to
respond
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Bool ean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri,
ICredentials credentials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role,
Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenStream(Uri uri)
at
System.Xml.XmlTextReaderImpl.DtdParserProxy_PushEx ternalSubset(String
systemId, String publicId)
at
System.Xml.XmlTextReaderImpl.DtdParserProxy.System .Xml.IDtdParserAdapter.PushExternalSubset(String
systemId, String publicId)
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.ParseInDocumentDtd(Boolean
saveInternalSubset)
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent( )
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at MetisDatabaseClass.MetisToDatabase.LoadMetisXMLDoc ument() in
D:\Visual Studio 2005
Projects\MetisToDB\MetisDatabaseClass\ConvertMetis XMLToDatabase.vb:line
223
at MetisDatabaseClass.MetisToDatabase.GetContainers(T reeView&
pobj_TreeView) in D:\Visual Studio 2005
Projects\MetisToDB\MetisDatabaseClass\ConvertMetis XMLToDatabase.vb:line
359
at
MetisToDBFrontEnd.frmMetisDBFrontEnd.frmMetisDBFro ntEnd_Load(Object
sender, EventArgs e) in D:\Visual Studio 2005
Projects\MetisToDB\MetisToDBFrontEnd\frmMetisDBFro ntEnd.vb:line 61
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd,
Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at MetisToDBFrontEnd.startupModule.Main() in D:\Visual Studio 2005
Projects\MetisToDB\MetisToDBFrontEnd\startupModule .vb:line 12