Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:43:05+00:00 2026-06-12T08:43:05+00:00

I have this simple VBScript that sends an HTTP POST request and reads the

  • 0

I have this simple VBScript that sends an HTTP POST request and reads the returning HTML response.

Function httpPOST(url, body, username, password )  
  Set Http = CreateObject("Msxml2.ServerXMLHTTP")   
  Http.Open "POST", url, False, username, password  
  Http.setRequestHeader _  
              "Content-Type", _  
              "application/x-www-form-urlencoded"  
  Http.send body 
  pagestatus = Http.status
  if pagestatus<> "200" then
    httpPOST="Error:"& pagestatus
  else
    'httpPOST = Http.ResponseBody
    'httpPOST = Http.responseText
    Set objXMLDoc = CreateObject("MSXML.DOMDocument")
    objXMLDoc.async = False
    objXMLDoc.validateOnParse = False
    objXMLDoc.load(Http.ResponseBody)
    Set objNode = objXMLDoc.selectSingleNode("/html/body/center/img")
    httpPost = objNode.getAttribute("alt") 
  end if
End Function

The HTML response format is the following:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>---</title>
    </head>
    <body>
        <center>
            <img alt="You are now connected" src="pages/GEN/connected_gen.png">
        </center>
    </body>
</html>

The issue with this script is that it always returns Error: Object required: 'objNode'

I have tried so many variations of XML parsers, and finally gave up for every time I got the same error related to XML objects.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:43:06+00:00Added an answer on June 12, 2026 at 8:43 am

    Your first problem is addressed here: .load expects ‘A string containing a URL that specifies the location of the XML file’; so use .loadXml to check whether Http.ResponseBody
    contains data that MSXML?.DOMDocument can parse (your second problem).

    UPDATE:

    Something that ‘works’ (and why):

      Dim sHTML : sHTML = readAllFromFile("..\data\02.html")
      WScript.Echo sHTML
      Dim oXDoc : Set oXDoc = CreateObject("MSXML2.DOMDocument")
      oXDoc.async = False
      oXDoc.validateOnParse = False
      oXDoc.setProperty "SelectionLanguage", "XPath"
      If oXDoc.loadXML(sHTML) Then
         Dim ndImg : Set ndImg = oXDoc.selectSingleNode("/html/body/center/img")
         Dim httpPost : httpPost = ndImg.getAttribute("alt")
         WScript.Echo "ok", httpPost
      Else
         WScript.Echo "Error: " & trimWS(oXDoc.parseError.reason)
      End If
    

    output:

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <title>---</title>
        </head>
        <body>
            <center>
                <img alt="You are now connected" src="pages/GEN/connected_gen.png"/>
            </center>
        </body>
    </html>
    
    ok You are now connected
    

    MSXML2.DOMDocument will .loadXML (and parse) HTML code, provided it is ‘XML-valid’. Your HTML isn’t, because the img tag is not closed – the error message I got for your original code:

    Error: End tag 'center' does not match the start tag 'img'.
    

    How to proceed further depends on whether you are able/willing to change the HTML.

    UPDATE II:

    While you could do nasty things to .ResponseBody before you feed it to .loadXML – why not use a HTML tool to parse HTML:

      Dim sHTML : sHTML = readAllFromFile("..\data\01.html")
      WScript.Echo sHTML
      Dim oHF : Set oHF = CreateObject("HTMLFILE")
      oHF.write sHTML
      Dim httpPost : httpPost = oHF.documentElement.childNodes(1).childNodes(0).childNodes(0).alt
      WScript.Echo "ok", httpPost
    

    output:

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <title>---</title>
        </head>
        <body>
            <center>
                <img alt="You are now connected" src="pages/GEN/connected_gen.png">
            </center>
        </body>
    </html>
    
    ok You are now connected
    

    As the output shows, HTMLFILE accepts your ‘not-xml-closed’ img; the method to get what you really want should be sanitized, of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so my problem is this. I have a simple vbscript that sends an
Can anyone help me understand how MAPI works? I have this simple vbscript that
I have this simple script that I'm working on. I must admit, I'm totally
i have this simple code http://jsfiddle.net/U4Fj9/ the index of the visible image is always
We have an old process (VBScript) that reads a common mailbox and processes certain
I have this simple piece of code : int a = 1, b =
I have this simple code (for making things shorted, the important bits are probably
I have this simple redirection on my website and it does not rewrite my
I have this simple rule in my Makefile : PP=g++ -std=c++0x %.o: $.cpp $(PP)
i have this simple query : SELECT YEAR(P.DateCreated) ,MONTH(P.DateCreated) ,COUNT(*) AS cnt FROM tbl1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.