07.05.2014 Views

OpenSRS API Integration for XML

OpenSRS API Integration for XML

OpenSRS API Integration for XML

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

On Error GoTo err_Main<br />

pFileRequest = App.Path & "\Sample.<strong>XML</strong>"<br />

str<strong>XML</strong> = ""<br />

Set DocToSend = New MS<strong>XML</strong>2.DOMDocument<br />

If Not Read<strong>XML</strong>Document(pFileRequest, DocToSend) Then<br />

MsgBox "Cannot read " & pFileRequest & vbCrLf & _<br />

ErrNumber & ", " & ErrDescription, vbCritical<br />

Exit Sub<br />

End If<br />

If SendRequest<strong>XML</strong>(DocToSend, str<strong>XML</strong>, strURL) Then<br />

MsgBox "Response has come. " & str<strong>XML</strong><br />

' here you may save to file or reload in DOMdocument to parse<br />

Else<br />

MsgBox "Cannot send " & DocToSend.xml & vbCrLf & _<br />

ErrNumber & ", " & ErrDescription, vbCritical<br />

Exit Sub<br />

End If<br />

Set DocToSend = Nothing<br />

Exit Sub<br />

err_Main:<br />

ErrNumber = Err.Number<br />

ErrDescription = "Run-time ERROR in Main. " & Err.Description<br />

MsgBox "Error " & ErrNumber & ", " & ErrDescription, vbCritical<br />

End Sub<br />

Private Function SendRequest<strong>XML</strong>( _<br />

ByRef p<strong>XML</strong>Doc As MS<strong>XML</strong>2.DOMDocument, _<br />

ByRef pcTmp As String, _<br />

ByVal pstrURL As String _

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!