Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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…

792 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