Solved

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

Posted on 2006-10-20
2
1,159 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error in query expression 3 54
JQuery on multiple lines 3 17
GitHub 1 11
P3P validator , ASP, PHP ,Https and Http links 3 13
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 demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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