Msxml2 Error Handling
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the msxml2.serverxmlhttp timeout company Business Learn more about hiring developers or posting ads with us Stack Overflow
Createobject Msxml2 Serverxmlhttp
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 vbs error handling million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Vbscript msxml12.XMLHTTP error handling up vote 0 down vote favorite 1 I use this vbscript code, to download web msxml2.serverxmlhttp methods page: Dim oXML Set oXML = CreateObject("msxm12.XMLHTTP") oXML.Open "GET", "mysite.com", False oXML.Send If there is no such web site, I get an error 80004005, Unspecified error at line "oXML.Open ..." How can I handle this error in vbscript? I want to catch this error and show msgbox with my error, i.e. web page is not available. vbscript xmlhttprequest share|improve this question edited Jul 21 '14 at 11:29 panther 14.2k71943 asked Jul 21 '14 at 11:28 Michael 6481717 OK, msxml2, not 12 it was just a typo... this script runs OK, when the web page exists –Michael Jul 21 '14 at 12:45 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted There are at least three possible points of failure in your script. CreateObject may fail; e.g. if you use msxml12 (digit 1) instead of msxml2 (letter l). Such blunders should be fixed during development. .Open may fail; e.g. if you use "mysite.com" instead of a syntactically correct URL. If you get the URL at runtime, a 'look before you jump' check is advisable, an OERN can be used to catch bad URLs not found by your validation. .Send may fail; e.g. if the site is down or abandoned. This is a clear case for an OERN. The most important rule wrt OERN: Keep it local and short (Only one risky line between OERN and OEG0). Demo code: Option Explicit Dim sUrl For Each sUrl In Split("http://stackoverflow.com http://pipapo.org mysite.com") Dim oXML, aErr ' Set oXML = CreateObject("msxm12.XMLHTTP") Set oXML = CreateObject("msxml2.XMLHTTP.6.0") On Error Resume Next oXML.Open "GET", sUrl, False aErr = Array(Err.Number, Err.Description) On Error GoTo 0 If 0 = aErr(0) Then On Error Resume Next oXML.Send aErr = Array(Err.Number, Err.Description) On E
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. XSLT Concepts [MSXML] Using XSLT with the DOM or SAX Implementing Error Handling with XSLT and the DOM Implementing Error Handling with XSLT and the DOM XSLT HTML DOM File with Error http://stackoverflow.com/questions/24863986/vbscript-msxml12-xmlhttp-error-handling Handling XSLT HTML DOM File with Error Handling XSLT HTML DOM File with Error Handling XSLT HTML DOM File with Error Handling TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. XSLT HTML DOM File with Error Handling https://msdn.microsoft.com/en-us/library/ms761361(v=vs.85).aspx The following example adds error handling to qsalesregion.html. HTML File (qsalesregionwerrchk.html) HTML Copy
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. MSXML MSXML SDK Overview Handling MSXML Errors Handling MSXML Errors Error Handling with DOM Error Handling with DOM Error Handling with DOM Error Handling with SAX Error Handling with DOM DOMErrorHandling C/C++ example DOMErrorHandling JScript example Resource: books.xml for DOMErrorHandling example TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Error Handling with DOM This section shows you how to perform error handling with Document Object Model (DOM) in C/C++ and JScript.For DOMErrorHandling C\C++ example, you will need the following:Microsoft XML Core Services (MSXML) SDK version 6.0. To download the MSXML 6.0 SDK, go to MSDN.Microsoft Visual Studio 2008. To create DOMErrorHandling console application project follow the instructions in the Set Up My VisualC++ Project.To add the source code and run your DOMErrorHandling C/C++ application, see DOMErrorHandling C/C++ example. For DOMErrorHandling JScript example, you will need the following:MSXML version 6.0. To download MSXML 6.0, go to MSDN.Notepad and Windows Scripting Host. For instructions on how to create JScript application, see Set Up My JScript Project.To add the source code and run your DOMErrorHandling JScript application, see DOMErrorHandling JScript example. Show: Inherited Protected Print Export (0) Print Export (0) Share IN THIS ARTICLE Is this page helpful? Yes No Additional feedback? 1500 characters remaining Submit Skip this Thank you! We appreciate your feedback. Dev centers Windows Office Visual Studio Microsoft Azure More... Learning resources Microsoft Virtual Academy Channel 9 MSDN Magazine Community Forums Blogs Codeplex Support Self support Programs BizSpark (for startups) Microsoft Imagine (for students) United States (English) Newsletter Privacy & cookies Terms of use T