Solved

Object Required Error!?

Posted on 2002-04-26
8
2,647 Views
Last Modified: 2007-11-27
Hi!

     Help me get over this error :

     My ASP code looks like this:

     set xmlDoc=server.createobject("Microsoft.XMLDOM")
     xmlDoc.load("2.xml")
     xmlDoc.async="false"

     set docElement=xmlDoc.documentElement

     set cNodes= docElement.childNodes
************************************************************
Microsoft VBScript runtime error '800a01a8'

Object required

in "set childNode= docElement.childNodes"
************************************************************

2.xml:

<?xml version="1.0"?>

<controller>
     <action id="getClients"
          componentName="Client.Client"
          methodName="getClients"
          presentationAsp="show.asp"
     />
     <action id="getEmployees"
          componentName="Employees.Employees"
          methodName="getEmployees"
          presentationAsp="showEmployees.asp"
     />
</controller>

0
Comment
Question by:rajivraj164
[X]
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
  • 3
  • 2
  • 2
  • +1
8 Comments
 

Expert Comment

by:CharlesM
ID: 6972216
I usually call the root node by name, like so:

   set rootNode = xmlDoc.selectSingleNode( "*/root_name")

in your case that'll be,

   set cNodes = xmlDoc.selectSingleNode( "*/controller")

if, however, you're wanting the <action> children, try this:


   set rootNode = xmlDoc.selectSingleNode( "*/controller")
   set cNodes = rootNode.selectNodes( "action")


Charles
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 6972223
set async property before you call load. It could be that loading has not finished yet.
0
 

Author Comment

by:rajivraj164
ID: 6972288
Tried:

    set xmlDoc=server.createobject("Microsoft.XMLDOM")
    xmlDoc.async="false"
    xmlDoc.load("2.xml")
set rootNode = xmlDoc.selectSingleNode( "*/controller")
set cNodes = rootNode.selectNodes( "action")

and now I get:

Object required: 'rootNode'

If i Dim rootNode, I get


Object required

If i comment out set cNodes = rootNode.selectNodes( "action") , no error and obvious nothing is printed!!!!1

When I create the object, its fine..... when I try to use the obect, its bombs!

wht u say?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:CharlesM
ID: 6972316
You should Dim all your variables.
Also, try bypassing the rootNode and select just the children using:

set cNodes = xmlDoc.selectNodes( "*/action")

You may have to fidget with the syntax of the "*/action" (I'm doing this from mem).
If this doesn't work, ensure the xmlDoc is truly being loaded with your xml by printing the xml on the page (doing nothing else).

Charles
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 6972421
set xmlDoc=server.createobject("Microsoft.XMLDOM")
xmlDoc.async=false '<--- no string!!!!
xmlDoc.load("2.xml")

ASPGuru
0
 

Author Comment

by:rajivraj164
ID: 6982964
Well, just realised something. The file is not even being read!

Even when I try:
dim xmlDoc,bool
set xmlDoc=server.createobject("Microsoft.XMLDOM")
xmlDoc.async=false
bool=xmlDoc.load("2.xml")
response.write bool

I get false!!!!!!! bool is false :O ..... its not even reading the file!!!!!!!!

if I try:

dim xmlDoc,bool,str
set xmlDoc=server.createobject("Microsoft.XMLDOM")
xmlDoc.async=false
str="<hey></hey>"
bool=xmlDoc.loadXML(str)
response.write bool

Now, I get true!!!!!!!!


So, its a prob in reading the xml file.
0
 
LVL 11

Accepted Solution

by:
ASPGuru earned 50 total points
ID: 6983747
you need to provide the path....

try something like this:

bool=xmlDoc.load(Server.MapPath("2.xml"))


ASPGuru
0
 

Author Comment

by:rajivraj164
ID: 6985241
Wow! :) That Worked! Thanx a lot Guru and All other.


This is my ASP:

<%@ language=vbscript %>
<%option explicit%>

<%
dim xmlDocument,objNode,strVal
dim bool,nodelist,NamedNodeMapObj,size,i,requestType

requestType="getClients"



set xmlDocument = Server.CreateObject("Microsoft.XMLDOM")
xmlDocument.async = False

bool=xmlDocument.load(server.mappath("news.xml"))


Set objNode=xmlDocument.documentElement

size= xmlDocument.documentElement.childNodes.length





     set nodelist=objNode.childNodes

     for i=0 to size-1


          set NamedNodeMapObj=nodelist.item(i).attributes



             if NamedNodeMapObj.getNamedItem("id").nodeValue=requestType then

               response.write "<hr>"
               response.write "<b><u>For a request type of:</u></b> "
               response.write NamedNodeMapObj.getNamedItem("id").nodeValue
               response.write "<br><br>"
               response.write " <b>Name of Component:</b> "
               response.write NamedNodeMapObj.getNamedItem("componentName").nodeValue
               response.write "<br><br>"
               response.write " <b>Name of Component Method:</b> "
               response.write NamedNodeMapObj.getNamedItem("methodName").nodeValue
               response.write "<br><br>"
               response.write " <b>Name of Resulting ASP:</b> "
               response.write NamedNodeMapObj.getNamedItem("presentationAsp").nodeValue
               response.write "<hr>"



          end if


     next



%>

And the XML File is:

<?xml version="1.0"?>

<controller>
    <action id="getClients"
         componentName="Client.Client"
         methodName="getClients()"
         presentationAsp="show.asp"
    />
    <action id="getEmployees"
         componentName="Employees.Employees"
         methodName="getEmployees()"
         presentationAsp="showEmployees.asp"
    />
</controller>


Just wanted to know if its the right approach!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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