473,761 Members | 7,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading XML Node_text using microsoft.xmldo m

AnuSumesh
96 New Member
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>,<passwor d> 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.GetElement sByTagName(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.GetElements ByTagName(tag). item(0).childno des(0).text also
2. doc.selectsingl enode("/Domain_Credenti als/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 4224
GazMathias
228 Recognized Expert New Member
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
9859
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, this tool calcuates the rates and services and returns back all the different shipping rates. Below is the code trying to display the return response.
2
3176
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 newbie at xml and xsl This is my xml("index.xml")page(I can not change this, it comes to me this way. <?xml version="1.0" encoding="iso-8859-1" ?>
0
1393
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. Turn an attribute a color when it falls below a certain level.
2
2757
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 the 'firstChild' of the xml document. here is the code; ---------------------------------------------------------------- <html>
2
16053
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 ID="Adhesive"> <ItemType>Machine</ItemType>
3
3601
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 Internet Explorer on Window-XP. Below I give all the files I'm using. Look at following code: File: Test.html
1
3783
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: xml_http.Send("") that gets stuck. I am on IIS 6 on Windows Server 2003 Web Edition. <% pcode = request.querystring("postcode") source2 = "http://3rdparty.com/addresslist.pce?postcode=" & pcode
0
1409
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
2530
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 "POST" Set xmldom = CreateObject("Microsoft.XMLDOM") xmldom.loadXML thexml2 xmlhttp.send xmldom
0
9531
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.