Solved

MSXML2.DOMDocument & ASP in IE

Posted on 2002-05-29
6
879 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

691 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