• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2761
  • Last Modified:

Object Required Error!?

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
rajivraj164
Asked:
rajivraj164
  • 3
  • 2
  • 2
  • +1
1 Solution
 
CharlesMCommented:
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
 
naveenkohliCommented:
set async property before you call load. It could be that loading has not finished yet.
0
 
rajivraj164Author Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
CharlesMCommented:
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
 
ASPGuruCommented:
set xmlDoc=server.createobject("Microsoft.XMLDOM")
xmlDoc.async=false '<--- no string!!!!
xmlDoc.load("2.xml")

ASPGuru
0
 
rajivraj164Author Commented:
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
 
ASPGuruCommented:
you need to provide the path....

try something like this:

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


ASPGuru
0
 
rajivraj164Author Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now