Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2009, 09:19 AM
Authorized User
 
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default trouble using Msxml2.DOMDocument.6.0 on IIS7

I'm trying to move a Classic ASP app from WinXP Pro IIS6 to Win2K8 IIS7. The app has the following function (and many more like this):
Code:
function findXmlRecord(strXmlFile, strXPath)
'This function returns an array holding all child node values where xmlDoc.ChildNodes(0).IdAttributeValue = valueStoredInDb
'The function expects the following 2 arguments:
' 1) strXmlFile - <string> xml file name
' 2) strXPath - <string> XPath query criteria
 Dim xmlDoc, oNode, cNodes, i
 Dim arReturn()
 Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument.6.0")
 xmlDoc.async = False
 If xmlDoc.load(Session("appDataPath") & strXmlFile) Then
  xmlDoc.setProperty "SelectionLanguage", "XPath"
  Set oNode = xmlDoc.selectNodes(strXPath)
  Set cNodes = oNode.item(0).childNodes
  Redim arReturn((cNodes.Length)-1) 'length is not zero based so have to do minus 1
  For i = 0 to ((cNodes.Length)-1)
   arReturn(i) = cNodes(i).text
  Next
  Set oNode = Nothing
  Set cNodes = Nothing
 End If
 set xmlDoc = nothing
 findXmlRecord = arReturn
end function
function call example:
Code:
   Response.Write(findXmlRecord("lists/classNames.xml", "/classNames/className[@ID = '" & oRs("classNameId") & "']")(0))
portion of the xml file:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Do not change any ID values in this document as they are stored in the GT database -->
<classNames>
 <className ID="1">
  <classNameText>Other</classNameText>
  <classNameSort>AAA</classNameSort>
 </className>
 <className ID="2">
  <classNameText>Study Hall</classNameText>
  <classNameSort>AAA</classNameSort>
 </className>
 <className ID="3">
  <classNameText>NILD</classNameText>
  <classNameSort>AAA</classNameSort>
 </className>
 <className ID="4">
  <classNameText>Art 6</classNameText>
  <classNameSort>BBB</classNameSort>
 </className>
 <className ID="5">
  <classNameText>Art I</classNameText>
  <classNameSort>BBB</classNameSort>
 </className>
 <className ID="6">
  <classNameText>Art II</classNameText>
  <classNameSort>BBB</classNameSort>
 </className>
 <className ID="7">
  <classNameText>Art III</classNameText>
  <classNameSort>BBB</classNameSort>
 </className>
 <className ID="8">
  <classNameText>Art IV</classNameText>
  <classNameSort>BBB</classNameSort>
 </className>
 <className ID="11">
  <classNameText>Art MC</classNameText>
  <classNameSort>BBB</classNameSort>
 </className>
</classNames>
On my laptop running XP Pro (and I think IIS6) I can call findXmlRecord just fine placing all className childnodes into an array where the className node ID attribute value = oRs("classNameId"). However the whole app comes crashing down when I copy it to my Win2K8 server running IIS7. What's weird is that I don't get any error messages, it's just that whenever I try to harvest data from my xml documents via "Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument.6.0")" I get absoulutly no data. Like I said it works perfectly on my XP machine.

Can anyone give me some direction?

Thanks
 
Old May 13th, 2009, 09:41 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well, "the whole app comes crashing down" and "I get absolutely no data" are quite different things in my understanding. If no data is found then I would debug the function you have, for instance you do
Code:
If xmlDoc.load(...) Then
but you have no Else branch checking xmlDoc.parseError.errorCode/reason.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old May 13th, 2009, 11:37 AM
Authorized User
 
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Martin,
I did modify the If Then statement to include an Else branch as follows:
Code:
 Else
  arReturn(0) = xmlDoc.parseError.errorCode
 End If
and the function is now returning an errorCode -2147024893 which I can't find anywhere on the web.

Do you have access to the load method's return values?

Thanks again for your help.

Darin
 
Old May 13th, 2009, 11:46 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Simply check/output the other parseError properties like parseError.reason in your function. Or return them if that is what you want. As errorCode is not zero the file could not be successfully loaded or parsed, the reason property should tell you in plain language why.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old May 13th, 2009, 12:18 PM
Authorized User
 
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default

very good

Code:
  arReturn(0) = "Error Code: " & xmlDoc.parseError.errorCode & ", Reason: " & xmlDoc.parseError.reason & ", Error Line: " & xmlDoc.parseError.line
returns:
Error Code: -2147024893, Reason: The system cannot find the path specified. , Error Line: 0

Are there any special file permissions I have to give the Network Service or Internet_Guest account to read the xml files? Not sure why the path works on my xp box but not on the server.

Thanks Martin
 
Old May 13th, 2009, 12:42 PM
Authorized User
 
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Got it. Turns out the folder structure differs between my XP box and the server, so the Session("appDataPath") needed changed in global.asa on the server. When I stated the whole site comes crashing down I meant that every reference to a xml file was failing - these references are scattered throughout the app. I edited the Session("appDataPath") value to match the server folder structure and everything is now working as it does on my xp box.

Thank you again Martin for your exellent pointers, your help is the reason for my success.

Darin
 
Old May 13th, 2009, 12:49 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Usually in classic ASP you use Server.MapPath("lists/classNames.xml") to map the web directory path to a file system path. Other than that I am not sure what to suggest. It could also be a permission issue but I am afraid I know nothing about the IIS 7 and Win 2008 server. Wrox has a classic ASP forum and Microsoft has IIS forums: http://forums.iis.net/, maybe someone there has more experience with IIS and setting up permissions for the user classic ASP is run with.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista/IIS7 Setup hyarmion BOOK: Beginning ASP 3.0 0 November 3rd, 2008 01:33 AM
IIS7: Can't display downloaded file idea_talk Internet Information Services 1 September 26th, 2008 06:37 PM
IIS7 and Vista makintosh BOOK: Beginning ASP 3.0 2 January 31st, 2008 06:06 PM
DomDocument is not working for me nikul PHP How-To 0 December 24th, 2007 07:47 AM
XML using MSXML2.DOMDocument object pankaj_daga Beginning VB 6 1 May 26th, 2006 08:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.