473,320 Members | 2,133 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,320 software developers and data experts.

XML reader

Hi,

I have a XML file which consists of several elements and I would like to
retrieve the value of 1 element particularly.

for example :

....
<Database_Location>
C:\test\db1.mdb
</Database_Location>

I try to get the value of "C:\test\db1.mdb" with the following code :

While XmlRead.Read
If (XmlNodeType.Element) Then
If (XmlRead.Name = "Database_Location") Then
MsgBox("before : " & XmlRead.Value)
End If
End If
End While

but every time I get the Value empty...why ?

thanks a lot,
Maileen
Nov 21 '05 #1
3 1147

try:

Dim tmpXML As New Xml.XmlDocument
Dim database_location As String
tmpXML.Load(licensefile)
database_location = tmpXML.GetElementsByTagName("Database_Location").I tem(0).InnerText
Hi,

I have a XML file which consists of several elements and I would like to
retrieve the value of 1 element particularly.

for example :

....
<Database_Location>
C:\test\db1.mdb
</Database_Location>

I try to get the value of "C:\test\db1.mdb" with the following code :

While XmlRead.Read
If (XmlNodeType.Element) Then
If (XmlRead.Name = "Database_Location") Then
MsgBox("before : " & XmlRead.Value)
End If
End If
End While

but every time I get the Value empty...why ?

thanks a lot,
Maileen


Nov 21 '05 #2
Maileen,

You can try this sample I made once as well
\\\\
Dim xmlString As String = "<department>" & _
"<employee name=""ABC"" age=""31"" sex=""male""/>" & _
"<employee name=""CDE"" age=""40"" sex=""male""/></department>"
Dim sr As New System.IO.StringReader(xmlString)
Dim doc As New Xml.XmlDocument
doc.Load(sr)
'or just in this case doc.LoadXML(xmlString)
Dim reader As New Xml.XmlNodeReader(doc)
While reader.Read()
Select Case reader.NodeType
Case Xml.XmlNodeType.Element
If reader.Name = "employee" Then
MessageBox.Show(reader.GetAttribute("name"))
End If
End Select
End While
///

Cor

"Maileen" <no****@email.com>
....
Hi,

I have a XML file which consists of several elements and I would like to
retrieve the value of 1 element particularly.

for example :

...
<Database_Location>
C:\test\db1.mdb
</Database_Location>

I try to get the value of "C:\test\db1.mdb" with the following code :

While XmlRead.Read
If (XmlNodeType.Element) Then
If (XmlRead.Name = "Database_Location") Then
MsgBox("before : " & XmlRead.Value)
End If
End If
End While

but every time I get the Value empty...why ?

thanks a lot,
Maileen

Nov 21 '05 #3


Maileen wrote:

I have a XML file which consists of several elements and I would like to
retrieve the value of 1 element particularly.

for example :

...
<Database_Location>
C:\test\db1.mdb
</Database_Location>

I try to get the value of "C:\test\db1.mdb" with the following code :

While XmlRead.Read
If (XmlNodeType.Element) Then
If (XmlRead.Name = "Database_Location") Then
MsgBox("before : " & XmlRead.Value)


You need to use
XmlRead.ReadElementString()
to get at the content of the Element node.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Stephan | last post by:
I'm fairly new to python and am working on parsing some delimited text files. I noticed that there's a nice CSV reading/writing module included in the libraries. My data files however, are odd...
8
by: Todd Bright | last post by:
Is there a way to get the current XmlNode from the reader while in the validation event handler? What I'd like to do is display the error message along with the name of its parent node. In my...
1
by: Anand | last post by:
I just implemented a program to solve reader writter prob. Wenever I run the program it seems to go into S+ state and it waits there I dont know why. When i attach gdb to one of the childs and step...
1
by: Aaron | last post by:
I asked for a script that can read info inside a specific xml tag and someone gave me this example. XmlReader reader = new XmlTextReader( filename ); while ( reader.Read() ) { if (...
12
by: Jerry Camel | last post by:
Not sure if this is a good place to post this... I'm writing and ASP.net app using vb .net. I need to interact with a credit card reader. I have one that sits inline with the keyboard. Works...
6
by: Karl Seguin [MVP] | last post by:
The BinaryWriter/Reader's are little-endian only. Was hoping they were going to be made more flexible in 2.0, but that doesn't appear to be the case. Anyone already done all the work of...
5
by: Dylan Parry | last post by:
Hi, At the moment I use code like the following: string myString = this.dataReader.IsDBNull(2) ? null : this.dataReader.GetString(2); With a record from the DB that looks like: ...
1
by: vbDavidC | last post by:
Hi, I am fairly new to .net and objects. I learned to create a reader object in method 1, however if I wanted to create multiple select queries in the same module I did not know how to reuse...
6
by: dgleeson3 | last post by:
Hello All I have VB code (.Net 2005) reading from an SQL server 2005 database. Im getting InvalidCastException when doing reader.GetInt32(0) Im simply reading an int from a simple database. It...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all people, everybody, We have multiple versions of Acrobat Reader from 5.x to 8.x, I want to create a method in C# or VB.NET to check to see if the registry key for the versions...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.