473,505 Members | 15,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to skip validation of DTD file on VB.Net when the DTD is offline

------- 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

Oct 19 '06 #1
1 3960
Ok - So the following solution works:
Dim lobj_XMLTextReader As XmlTextReader
Dim iobj_MetisModel As New XmlDocument
'Start up the XmlTextReader - using this to override the
XMLResolver
lobj_XMLTextReader = New XmlTextReader(is_Path_To_File)
lobj_XMLTextReader.XmlResolver = Nothing
iobj_MetisModel.Load(lobj_XMLTextReader)

this was a pain - I hope it helps others :)

Dec 6 '06 #2

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

Similar topics

72
5137
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
2
1696
by: Joe Au | last post by:
I create a (left) panel control to hold some image buttons, and a (right) panel to hold some textboxes and corresponding validation controls. When I press one of the button on the left panel, then...
2
1978
by: Jayson | last post by:
Hi guys, I am using a control(I only got the dll file) downloaded from web. Whenever a key is enter it will validate the user input. If not valid it will ignore the key being enter. I want to...
4
2705
by: ron | last post by:
I have a access based guest book. I want to create a validation rule to block certain words or parts of a srting. How do i do this? ie: this is a nice site. come visit my porn site at www.abc.zy...
1
2349
by: harriegovin | last post by:
Hi, Here is the scenario. I have a web application written in vb.net. One of the functionalities of the application is to save the recordset in an xml format on to the client machine. The xml...
5
2535
by: matt | last post by:
hello, i am on an interesting project. in this project, i have to create dynamic data-entry forms for offline-users to fill out, save locally, and eventually postback to our app (when back...
0
1530
by: xievvv | last post by:
I am trying to have a SslStream client and an SslStream server mutually authenticate and communicate with each other, over TCP. So when I call the methods AuthenticateAsClient() and...
1
1914
by: shakthi | last post by:
Hi I created an online Mobile application using .net 2.0 on server side and another offline application on mobile client using .net compact framework 2.0. I packaged my offline application to CAB...
8
2837
by: Jean Pierre Daviau | last post by:
Ho to everyone, ======== http://validator.w3.org/check?uri=' =========== I would like to rewrite this script to validate files from my desktop. Thanks for your attention.
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
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
7303
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,...
1
5028
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
4699
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...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
407
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.