XML

A

ats@jbex

I have a program that sends an xml document to a third party using https
POST and the msxml.xmlhttp library. How do I get the reply xml document
into the DomDocument object?

TIA
--
ats@jbex

When Johnny comes marching home again
He's coming by bus or underground
A woman's eye will shed a tear
To see his face so beaten in fear
An' it was just around the corner in the English Civil War

The Clash - English Civil War
 
M

Martin Honnen

ats@jbex said:
I have a program that sends an xml document to a third party using https
POST and the msxml.xmlhttp library. How do I get the reply xml document
into the DomDocument object?

Are you using MSXML with .NET? That is not supported:
http://support.microsoft.com/kb/815112/en-us

As for a DOM document, the responseXML property of the XMLHttp object is
an XML DOM document. It is populated if the response is sent as
Content-Type application/xml or text/xml.
 
A

ats@jbex

Are you using MSXML with .NET? That is not supported:
http://support.microsoft.com/kb/815112/en-us

As for a DOM document, the responseXML property of the XMLHttp object is
an XML DOM document. It is populated if the response is sent as
Content-Type application/xml or text/xml.

Thanks for the reply. I am using MSXML with VB6. The response is coming
from a payment service and I would imagine it is in the correct format.
However when I tell my DOM document to load it it fails.
--
ats@jbex

Boats an' tanks and planes, it's your game
Kings an' queens an' generals learn your name
I see all the innocents, the human sacrifice
And if death comes so cheap
Then the same goes for life!

The Clash - Tommy Gun
 
A

ats@jbex

On Mon, 28 Apr 2008 08:02:07 +0100, ats@jbex wrote:

Here is the code I am using:

Sub SendPmt()

Dim xmlObj As MSXML2.XMLHTTP26
Dim xmldoc As DOMDocument26
Dim xNode As MSXML2.IXMLDOMNode
Dim Nodes As MSXML2.IXMLDOMNodeList

Dim url As String

Dim responset As String
Dim responsex As String
Dim response As String

Dim sUser As String
Dim sPass As String

Set xmlObj = New MSXML2.XMLHTTP26
Set xmldoc = New DOMDocument26

'set username and password
sUser = "uname"
sPass = "pwd"

'set url
url = "https://somesite"

'set up the document
xmldoc.async = False
xmldoc.resolveExternals = False
xmldoc.validateOnParse = False
xmldoc.Load xmlPmt 'a document with a .xml extension

'parse for errors
If xmldoc.parseError = 0 Then
MsgBox "Parsed OK"
Else
MsgBox "Not Parsed" & vbCrLf & err.Number & vbCrLf &
err.Description
End If

'post the xml
xmlObj.Open "POST", url, False, sUser, sPass
xmlObj.SetRequestHeader "Content-Type", "text/xml"
xmlObj.Send xmldoc.XML

'get the response text
responset = xmlObj.ResponseText

'and the xml - THIS PART THROWS AN ERROR
responsex = xmlObj.responseXML

'try to load the response - AS RESPONSEXML DOESN'T WORK TRIED IT WITH
RESPONSETEXT INSTEAD
If xmldoc.Load(responset) Then
Set Nodes = xmldoc.ChildNodes
For Each xNode In Nodes
If xNode.nodeName = "lastEvent" Then
response = xNode.Text
End If
Next xNode
Else
response = "Failed to load"
End If

MsgBox response & vbCrLf & responset, vbOKOnly + vbInformation,
gAppname

The code work fine for sending an xml document but fails to load the
response. Am I doing something wrong?

End Sub

--
ats@jbex

Don't believe them
Don't believe them
Question everything you're told

SLF - Suspect Device
 
A

ats@jbex

Any reason for not using .NET framework classes ? If you are not working
with .NET you may want to post to another group...

What is the error you get ? I would try just the load part possibly on a
simplified XML document to check if this is the XML content that make the
load fails...

Thanks for the reply. Sorry I appear to have posted to the wrong group.
Please accept my apologies. I will move the post to another group if I
don't get it working this afternoon.
--
ats@jbex

They say they've got control of you
But that's not true you know
They say they're a part of you
And that's a lie you know
They say you will never be
Free free free

SLF - Alternative Ulster
 
M

Martin Honnen

ats@jbex said:
Dim responsex As String

'and the xml - THIS PART THROWS AN ERROR
responsex = xmlObj.responseXML

responseXML is an DOM document object not a string:
Dim responseDoc As MSXML2.IXMLDOMDocument
Set responseDoc = xmlObj.responseXML

Note that I have cross-posted to the xml group and set followup also to
move this from the VB.NET group to a more appropriate forum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top