p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP 3.0 (http://p2p.wrox.com/forumdisplay.php?f=27)
-   -   Problems with Ch. 18 example (http://p2p.wrox.com/showthread.php?t=5758)

tomephillips November 4th, 2003 03:28 PM

Problems with Ch. 18 example
 
I have not been able to get the DomExample1.asp script to work. Downloaded the code off of the web site and tried it as well.

All I get is "An error occurred on the server when processing the URL. Please contact the system administrator."

All other asp files work ....

Any ideas?
Thanks.....

Imar November 4th, 2003 04:18 PM

Hi there,

Can you post the code for the example? Not everyone has the book so it's a bit hard to guess what the problem is.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

tomephillips November 5th, 2003 08:47 AM

Here is the asp code:

<%
'create an instance of MSXML to retreive the book details
set objXML = Server.CreateObject("microsoft.XMLDOM")

'load the XML document that we want to add to the database
objXML.load("c:\BegASP3Files\Ch18\XMLFiles\books.x ml")

'see if it loaded OK, i.e. is a well-formed XML file
If objXML.parseError.errorCode = 0 Then
  strTitle = objXML.documentElement.firstChild.firstChild.text
  strISBN = objXML.documentElement.firstChild.childNodes(1).te xt
  strDescription = objXML.documentElement.firstChild.childNodes(3).te xt

  Response.Write (strTitle & "<BR>")
  Response.Write (strISBN & "<BR>")
  Response.Write (strDescription & "<BR>")

'write out if an error occured
Else

  Response.Write ("Sorry, an error occurred retreiving information.")

End If

Set objXML = nothing
%>

Here is the books.xml:

<?xml version="1.0"?>
<books>
<book>
   <title>Beginning ASP 3.0</title>
   <ISBN>1-861003-38-2</ISBN>
   <authors>
      <author_name>Brian Francis</author_name>
      <author_name>Chris Ullman</author_name>
      <author_name>Dave Sussman</author_name>
      <author_name>John Kauffman</author_name>
      <author_name>Jon Duckett</author_name>
      <author_name>Juan Llibre</author_name>
   </authors>
   <description> ASP is a powerful technology for dynamically creating web site content. Learn how to create exciting pages that are tailored to your audience. Enhance your web/intranet presence with powerful web applications.</description>
   <price US="$49.99"/>
</book>
</books>

-----

I have tried:
set objXML = Server.CreateObject("Msxml2.DomDocument.3.0")

as other posts have suggested that microsoft.XMLDOM is very outdated.

The script fails on:
strTitle = objXML.documentElement.firstChild.firstChild.text

Thanks....

Imar November 5th, 2003 03:24 PM

What OS are you running? This sample code ran fine on my machine after I made a small modification:

objXML.load(Server.MapPath("books.xml"))

Instead of using a hard coded path, I used Server.MapPath to convert the virtual location of the XML to a physical location on disk. However, if the file is located at the location you had in your code, it should run.

Did you install one of the latest version of XML from Microsoft? You may need to install a recent version of the XML parser from this location: http://msdn.microsoft.com/library/de...xmlgeneral.asp

Once you install the latest version, you should be able to instantiate a DOM Object with this progid: Msxml2.DOMDocument.4.0

HtH,

Imar




---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

Imar November 5th, 2003 03:25 PM

In addition to this, check out this MSDN page:

http://msdn.microsoft.com/library/de...asp?frame=true

In the navigation tree on the left you'll find the full XML reference with lots of examples and explanations.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

tomephillips November 6th, 2003 08:25 AM


Huh .... that did it!

I thought that I'd tried that before, but I guess not.

So simple now!

Thanks for your help.


All times are GMT -4. The time now is 07:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.