View Single Post
  #3 (permalink)  
Old November 5th, 2003, 08:47 AM
tomephillips tomephillips is offline
Registered User
Join Date: Nov 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

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

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

End If

Set objXML = nothing

Here is the books.xml:

<?xml version="1.0"?>
   <title>Beginning ASP 3.0</title>
      <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>
   <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"/>


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