?
Solved

MSXML2.DOMDocument & ASP in IE

Posted on 2002-05-29
6
Medium Priority
?
885 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 300 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

752 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