Setting XML Object and Reusing It From Different Directories

Discussion in 'ASP General' started by vunet, Mar 4, 2010.

  1. vunet

    vunet Guest

    Hello,
    I am not able to load XML using Load method from child directory
    (unlikely security issue). The function below sets xmlObj object once
    and reuses this object every time it is accessed to loop through some
    nodes. However, if I run this function from child directory, xmlObj
    object contains no nodes even though it exists and loads XML without
    errorCode. I achieved success if I set a new object (with new name)
    but this would add complexity to my app and I want consistency to
    reuse one object cross whole app. Please tell me what can be done in
    my case and why xmlObj does not have children from child directory.


    set xmlObj = nothing
    function setAppXML ()
    setAppXML = true 'default
    if xmlObj is nothing then
    Set xmlObj = Server.CreateObject("Microsoft.XMLDOM")
    xmlObj .async = False
    setAppXML = xmlObj.Load (Server.MapPath(PageDepth&"db/
    appdata.inc"))
    if xmlObj.parseError.errorCode > 0 then
    setAppXML = false
    resonse.write "Error parsing XML: "&xmlObj.parseError.errorCode
    end if
    end if
    end function


    ''''''somewhere later I do
    If setAppXML = true Then Set objConfig =
    xmlObj.getElementsByTagName("config")
    'BUT if I run function from any child directory then
    objConfig.item(0).childNodes has NO NODES
     
    vunet, Mar 4, 2010
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.