Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Validate?

Status
Not open for further replies.

jimny

Technical User
Oct 18, 2002
52
US
I have an ASP app that interfaces with an app that returns its results in XML. I have had a randomly recurring problem with the server returning an "Object Required" error message regarding my "TopNode" which is the XMLDoc.FirstChild. I have tried various ways of error checking, with no improvement, and Am now trying the "Validate" method. Can anyone tell me if the following code makes sense, Since the error occurs randomly and I have no way of truly knowing if this will capture the error.


ResponseXML = agent.SendRequest(RequestDoc.XML)
Set XMLDoc = Server.CreateObject("MSXML.DOMDocument")
XMLDoc.loadXML(ResponseXML)
Set ValidateError = XMLDoc.validate
if not ValidateError.errorCode <> &quot;&quot; then
set rsp= XMLDoc.selectSingleNode(&quot;/rca_response&quot;)
if rsp.text <> &quot;&quot; then
Set TopNode = XMLDoc.firstChild
If TopNode.NodeName = &quot;rca_response&quot; Then
Set ResponseNode = TopNode.firstChild
If Responsenode.NodeName = &quot;response&quot; then
Set resultNode = responseNode.firstchild
If resultNode.NodeName = &quot;error&quot; then
my processing...
else
other processing...
end if
end if
end if
end if
end if

I know that there is a lot of VBScript in there as well, butI thought that if i diplayed the whole logic, it would make it a little easier.
I have also tried &quot;If topNode.haschildnodes()or topnode is nothing then..&quot;
I know there has to be amore efficient way of doing this.

thanks for indulging a fool.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top