Solved

Variable is undefined: 'oXML' - classic ASP (Building an XML FIle)

Posted on 2006-10-20
2
1,142 Views
Last Modified: 2008-02-01
I need some help with error message about an xml  variable not being undefined.  I am trying to create an xml file from a classic ASP program but the I am getting an error on lione 286 as documented below.  Any suggestions?  

line 286 -  Set oXML = Server.CreateObject("Microsoft.XMLDOM")

Error Type:
Microsoft VBScript runtime (0x800A01F4)   Variable is undefined: 'oXML'
/Apogee/residential/account_history2.asp, line 286

My Code:

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Response.Write("Test 2")
      ' find xml file path  
 dim strFilename,strXMLFile  
 strFilename = "Apogee.xml"  
 strXMLFile=server.mapPath(strFilename)  
 Set oXML = Server.CreateObject("Microsoft.XMLDOM")
 Set oXML.DocumentElement = oXML.createElement("P21_VPT_DATA")
 
 ' check file exists  
 bitFileExists = oXML.load(strXMLFile)  
 
 if bitFileExists then  
 tmpChildnodes = oXML.documentElement.childnodes.length - 1  
 intCurrentRecord = tmpChildnodes + 1  
 else  
 ' create xml  
 oXML.appendChild(oXML.createProcessingInstruction("xml","version=""1.0"""))  
 oXML.appendChild(oXML.createElement("BillingData"))  
 intCurrentRecord = 0  
 end if  
 
 ' create record  
 Set oXMLRec = oXML.createElement("UtilityId")  
 
 ' Create an id attribute  
 Set oAtt = oXML.createAttribute("id")  
 oAtt.Text = intCurrentRecord  
 oXMLRec.SetAttributeNode oAtt  
 
 ' Set remaining fields  
           
 for HRi = 0 to UBound(results, 2)
 ' name  
 Set oXMLData = oXML.CreateElement("BillingCycleData")
 oXMLRec.appendChild(oXML.createElement("meterReadDate"))
 oXMLRec.appendChild(oXML.createElement("revenue"))  
 oXMLRec.appendChild(oXML.createElement("usuage"))  
 oXMLRec.childnodes(0).text = results(BILL_DATE, HRi)
 oXMLRec.childnodes(1).text = results(BILL_AMOUNT, HRi)  
 oXMLRec.childnodes(2).text = results(KILOWATT_USAGE, HRi)
 oXML.DocumentElement.AppendChild oXMLData.cloneNode(true)
 next
 

 oXML.documentElement.appendChild(oXMLRec.cloneNode(True))  

 oXML.save strXMLFile  

 response.redirect(strFilename)  
 oXML = Nothing  
 end if

0
Comment
Question by:Hojoformo
  • 2
2 Comments
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 17775378
Hojoformo,

Are you using Option Explicit so that you are required to define variables?  Add the line below just above the line with the error.

Dim oXML

If that doesn't fix it let me know.  Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17775915
I'm glad that I could help.  Thank you for the grade, the points and the fun question.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now