perfectxml.com
 Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
home » focus » msxml » ask a question » past questions & answers Friday, 12 October 2007
 
NEWS
MSXML 4.0 SP2 now available!

 
MSXML
Basics
DOM
SAX
XPath
XSLT
Schemas
SOM
HTTP Access
.NET
Data Islands
Ask a Question
   Past Q&As
C++ Samples
DLL/Version Info
Reference Guide
Books
KB Articles
   HOW TO
   SAMPLE
   INFO
   BUG/PRB
   FIX
   Misc.
MSXML Tips
   August 2002
   September 2002
MSXML Tools

Microsoft XML Core Services


Go back to list of previously asked questions and answers

Question: I am loading a large XML document, and the load method always times out. How can I set the timeout setting while loading the XML document using DOM?
Asked By: Frank
Viewed: 2741
Answer: Unfortunately, MSXML DOM (yet) does not support directly specifying timeout settings. If it possible for you to use ServerXMLHTTP (assuming you are not running on Win9x/Me and can use MSXML 3.0 and above), you can set the timeout properties, send a GET request for the XML file, and use the responseXML property as illustrated below:

Create a new Visual Basic 6.0 Standard EXE project, add reference to MSXML 3.0 type library, and write the following code in the Form_Load method:

Dim objSXH As New MSXML2.ServerXMLHTTP30

objSXH.setTimeouts 30000, 30000, 0, 0
objSXH.open "GET", "https://perfectxml.com/books.xml", False
objSXH.send

If objSXH.Status = 200 Then
    MsgBox objSXH.responseXML.xml
Else
    MsgBox "Error: " & objSXH.statusText
End If

The setTimeouts methods allows specifying resolveTimeout (30 seconds in the above code), connectTimeout (30 seconds above in the above code), sendTimeout (infinite timeout in the above code), and receiveTimeout (infinite timeout in the above code).

The responseXML property is of type DOMDocument and the parser does not populate this property (load the received XML document in it), unless we first access it. You can use the responseXML property as a DOMDocument object.


Go back to list of previously asked questions and answers
  Contact Us |  | Site Guide | About PerfectXML | Advertise ©2004 perfectxml.com. All rights reserved. | Privacy