1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem while parsing a simple XML file

Discussion in 'C#' started by rag84dec, Aug 27, 2008.

  1. #1
    I have an XML file "r1.xml"
    
    <root>
        <val>Value1</val>
        <val1>value2</val1>
    </root>
    
    Code (markup):

    I have an ASP script file as below
    
    dim rootName12
    
     Set objXML = Server.CreateObject("Microsoft.XMLDOM")
     Set objLst = Server.CreateObject("Microsoft.XMLDOM")
     objXML.async = False
     objXML.Load (Server.MapPath("r1.xml"))
     If objXML.parseError.errorCode <> 0 Then
    	 'handle the error
     End If
     
    Set rootName12 =  objXML.documentElement
    
    Set nm= rootName12.childNodes.item(0).tagName [B]' I am 'getting error here[/B]
    
    Code (markup):

    But i am getting an error like this

    Microsoft VBScript runtime (0x800A01A8)
    Object required: 'rootName12'




    Can anyone help???

    thanks
     
    rag84dec, Aug 27, 2008 IP
  2. SearchBliss

    SearchBliss Well-Known Member

    Messages:
    1,899
    Likes Received:
    70
    Best Answers:
    2
    Trophy Points:
    195
    Digital Goods:
    1
    #2
    After a quick glance, I think the problem is with setting nm, it needs to be declared first, like this:
    dim rootName12, nm

    If this wasn't the issue, I'll take another look.
     
    SearchBliss, Aug 29, 2008 IP
  3. drax2006

    drax2006 Well-Known Member

    Messages:
    233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    118
    #3
    rootname is uninstantiated ie it has no value - or more specifically type

    (sorry I'm vb.net) but it needs to be something like

    dim rootname as object (late binding)
    or
    dim rootname as as xmldocument

    or whatever the asp equivalent is!
     
    drax2006, Aug 29, 2008 IP