Solved

MSXML2.DOMDocument & ASP in IE

Posted on 2002-05-29
6
871 Views
Last Modified: 2010-05-18
Dear all,

I've a problem about the use of MSXML2.DOMDocument by ASP in IE.

When I develop a dll file by VB and call the function f_foo(strXML) by ASP in IE, there is an error occurred at point 1.  

========== VB Side ================
'dll : COM_Task.dll
'Class Module : clsTaskUpd
Public Function f_foo(ByVal v_strXML) As String
 On Error GoTo lblErrHandler
 Dim strTemp As String
 Dim objDOM As MSXML2.DOMDocument

 Set objDOM = New MSXML2.DOMDocument
 objDOM.loadXML v_strXML

 '*** point 1 ***
 With objDOM.documentElement.childNodes.Item(0).childNodes
 '*** point 2 ***
    strTemp = .Item(COL_RECSTS).Text
 End With

 f_foo = strDate

lblErrHandler:
    Err.Raise Err.Number
Exit Function


========== ASP Side ================
Sub pp_DBUpd()
 Dim strNew_LstUpdDte
 Dim comTask

 mstrReq = Request.Form      ' the xml text

 On Error Resume Next
 Err.clear

 Set comTask = CreateObject("COM_Task.clsTaskUpd")
 strNew_LstUpdDte = comTask.f_foo(mstrReq)
 Set comTask = Nothing

End Sub

The Err.Number is 91 and the corresponding description is "Object variable or With block variable not set", according to MSDN.

With the help of expert "b1xml2" in here, I try to change the program as follow but the problem still exists at point 1.

'**** point 1 ****
Set objElement = objDOM.documentElement.firstChild
'**** point 2 ****

OR

'**** point 1 ****
Set objNodeList = objDOM.documentElement.childNodes
'**** point 2 ****

It seems that MSXML2.DOMDocument cannot be referenced and the objDOM.parseError.errorCode is -1072896659.  But I can't find this error code in MSDN.

In fact, I try to write a small VB program to run the same dll and it functions correctly.  Just don't know why the dll call fail when using ASP with IE.

Please kindly give me some idea about my problem.

My development environemt is as follow :
Chinese Win2000 Professional
Chinese VB6 with SP 5
VB Reference : Microsoft XML, v3.0
Chinese IE 6.0
IIS 5.0

Thanks for your sincerely help.
0
Comment
Question by:alan_cheung
  • 3
  • 2
6 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
ID: 7042875
Try this:

Public Function f_foo(ByVal v_strXML) As String
On Error GoTo lblErrHandler
Dim strTemp As String
Dim objDOM As MSXML2.DOMDocument

Set objDOM = New MSXML2.DOMDocument
If objDOM.loadXML(v_strXML) Then  ' Change this

   '*** point 1 ***
   With objDOM.documentElement.childNodes.Item(0).childNodes
   '*** point 2 ***
      strTemp = .Item(COL_RECSTS).Text
   End With

   f_foo = strDate
Else                  <-- Add this
   Err.Raise vbObjectError, "Source Name", "XML did not load!"
End If

Exit Function           <--Add this

lblErrHandler:
   Err.Raise Err.Number
Exit Function
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7042883
Also, please maintain your open questions:

Questions Asked 19
Last 10 Grades Given A A A A A B A A A B  
Question Grading Record 13 Answers Graded / 13 Answers Received

Thanks,
Anthony
0
 

Author Comment

by:alan_cheung
ID: 7043590
I think I get the point of my problem.  As acperkins suggest, objDOM.loadXML(v_strXML) cannot load the parameter successfully and therefore raise the error.  After check the MSDN, it point out that loadXML()will work only with UTF-16 or UCS-2 encodings.  Therefore I think it doese not work in my Chinese system.

If my parameter is in the following format, is there any suggestion to load the parameter into the DOM in the Chinese system?

<list>
  <row>
    <RecSts>r</RecSts>
    <CreBy>ADMIN</CreBy>
    <CreDte_str>2002/05/17 22:50:08</CreDte_str>
    <LstUpdBy>ADMIN</LstUpdBy>
    <LstUpdDte_str>2002/05/30 10:34:51</LstUpdDte_str>
  </row>
</list>

I'm not sure if I can raise the above question follow by this thread.  If it is necessary to create a new thread with the above issue, please let me know.

Thanks for your kind attention.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7043709
I really could not say.  A couple of suggestions:
1. Change your code as follows:

If objDOM.loadXML(v_strXML) Then

  '*** point 1 ***
  With objDOM.documentElement.childNodes.Item(0).childNodes
  '*** point 2 ***
     strTemp = .Item(COL_RECSTS).Text
  End With

  f_foo = strDate
Else
  Err.Raise vbObjectError, "Source Name", "XML did not
load! Reason:" & objDOM.ParseError.reason <-- Change this line
End If

This may give you additional information.  Also, checkout all the other properties of the IXMLDOMParseError object.

2.  Take a look at the load method.  I believe it may not suffer the same limitation.  In other words, try loading the XML document from a file.

Hope this helps,
Anthony
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7044026
Try this:-
===========
Public Function f_foo(ByVal v_strXML,Optional ByVal bolEncoding = False) As String
On Error GoTo lblErrHandler
Dim strTemp As String
Dim objDOM As MSXML2.DOMDocument
Set objDOM = New MSXML2.DOMDocument
If bolEncoding Then v_strXML = "<?xml version='1.0' encoding='utf-8'?>" & v_strXML
If objDOM.loadXML(v_strXML) = False Then
 Err.Raise vbObjectError,"", objDOM.parseError.reason
End If

...
...


End Function

The point being you are putting in the encoding attribute via the loadXML method.



0
 

Author Comment

by:alan_cheung
ID: 7072297
Since acperkins comment help me to sport the source of problem.  Therefore I would like to give the point to him/her.  For the source and solution of my problem, please refer to qid 20308020 at XML.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now