anusumesh 0 Newbie Poster

Hi,

I want to read the text property of XML file.
My xml file is as follows:

<?xml version="1.0"?>   
<Domain_Credentials>   
    <User> anu </User> 
    <Password> admin </Password> 
    <SearchBaseDN> dc=def,dc=com </SerachBaseDN> 
    <Host> abc.def.com</Host>       
</Domain_Credentials>

I want to read the values of <user>,<password> etc.

For reading these values, my code is as follows(in asp file):

file = "myfiles\DomainCredentials.xml" 
file=Server.MapPath(file) 
  tag="Host" 
    Set fso =server.CreateObject("Scripting.FileSystemObject") 
If fso.FileExists(file) Then 
set doc = CreateObject("Microsoft.XMLDOM") 
  
    if err.number <> 0 or doc is nothing then 
        light_trace "error creating xmldom: " & err.description 
    else 
        light_trace "create xmldom ok" 
    end if 
  
    doc.async = "false" 
    doc.load(file) 
  
    if err.number <> 0 or doc is nothing then 
        light_trace "error loading xml file: " & err.description 
    else 
        light_trace "xml file load ok" 
    end if                 
               Dim element 
               element="" 
               element=doc.GetElementsByTagName(tag).item(0).text 
    end if

My code failed at line "doc.GetElementsByTagName(tag).item(0).text".
Earlier a long time back, This code was working fine.
But now giving error.
And also please tell me how to retreive the error description for this line in asp?

I have tried following options also:
1. doc.GetElementsByTagName(tag).item(0).childnodes(0 ).text also
2. doc.selectsinglenode("/Domain_Credentials/Host").text

But no luck.

Can anyone please help me how to read these values from given xml file?

Regards,
anu