Solved

Object Required Error!?

Posted on 2002-04-26
8
2,626 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
  • 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
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.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
ASP Button to clear text 4 62
JQuery to parse xml string and get element by id 4 48
Call a function within the ASP code 4 19
JS does not refresh 6 30
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…
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…

828 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