473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Reading XML Node_text using microsoft.xmldom

AnuSumesh
Hi,

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

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2.  
  3. <Domain_Credentials>
  4.     <User> anu </User>
  5.     <Password> admin </Password>
  6.     <SearchBaseDN> dc=def,dc=com </SerachBaseDN>
  7.     <Host> abc.def.com</Host>    
  8. </Domain_Credentials>
  9.  
I want to read the values of <user>,<password> etc.

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

Expand|Select|Wrap|Line Numbers
  1.                 file = "myfiles\DomainCredentials.xml"
  2.                 file=Server.MapPath(file)
  3.     tag="Host"
  4.     Set fso =server.CreateObject("Scripting.FileSystemObject")
  5. If fso.FileExists(file) Then
  6. set doc = CreateObject("Microsoft.XMLDOM")
  7.  
  8.     if err.number <> 0 or doc is nothing then
  9.         light_trace "error creating xmldom: " & err.description
  10.     else
  11.         light_trace "create xmldom ok"
  12.     end if
  13.  
  14.     doc.async = "false"
  15.     doc.load(file)
  16.  
  17.     if err.number <> 0 or doc is nothing then
  18.         light_trace "error loading xml file: " & err.description
  19.     else
  20.         light_trace "xml file load ok"
  21.     end if                
  22.                Dim element
  23.                element=""
  24.                element=doc.GetElementsByTagName(tag).item(0).text
  25.     end if
  26.  
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
May 20 '09 #1
1 4197
GazMathias
228 Expert 128KB
What about:

Expand|Select|Wrap|Line Numbers
  1. doc.documentElement.childNodes(0).text
  2.  
Gaz.
May 26 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: VK | last post by:
Dear All: I have an issue trying to parse response from xml document, for that matter I don't receive back response. I am trying to integrate UPS e-commerce online tool into our web site,...
2
by: kmunderwood | last post by:
I am having trouble changing the font size when extracting xml into an html web page. I think it can be done so many ways, that my searches bring up examples that I am not familiar with. I am a...
0
by: kmunderwood | last post by:
I am having trouble excluding select xml out to HTML using xsl I want to ignore some xml and turn others red I can not find the right way to both: 1. Only show the <tag> that want to, and...
2
by: Kenneth | last post by:
I am tryint to view a xml document in Internet Exploer as a ActiveX object using Javascript but it does not work. I only see the button but nothing happens when i click it. I am trying to view...
2
by: Jim Mitchell | last post by:
I am getting an error... elem is null or not an object using the following Client side javascript. Can someone give me some help? Thanks in advance. <XML ID="PB"> <ProductItem> <Product ...
3
by: xq386 | last post by:
Question: In the XSL file below I put a part of the code (concerning the euro-sign) in comment. If I remove the comment then it doesn't work anymore. How can this be solved? I run Test.html with...
1
by: =?Utf-8?B?WmFnb3I=?= | last post by:
I have the code below and in a random fashion it is responding extremely slowly. On in 3-4 times it takes ages to do the job... Any help will be much appreciated... It is the line:...
0
by: tarundevnani | last post by:
I have a file named file1.xml also under C:/tarun/file1.xml file1.xml looks like:- <?xml version="1.0" encoding="UTF-8" ?> - <elemNames> <name>elem1</name> </elemNames> Method 1:
2
by: Joey Martin | last post by:
I'll try to make my explanation as thorough as possible. I am trying to grab the value of the node that is returned. MY CODE: Set xmlhttp = CreateObject("Microsoft.XMLHTTP") xmlhttp.open...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.