Home > error handling > msxml2 error handling

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 Quarterly Sales, by Region

 

© Copyright 2019|winbytes.org.