473,387 Members | 1,561 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,387 software developers and data experts.

reading an xml file for a value

hey all,

all i'm trying to do is retrieve text value from a particular node. and i
can get it the way shown below but was wondering if there was a cleaner way.
Because right now i'm looping thru the xml file looking for a particular node
and when it finds it i go ahead and read one more time to advance to the
value of the node. is this how it's normally done?
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Element 'Display beginning of element.
If reader.Name = "strSearch" Then
reader.Read()
RichTextBox1.AppendText(reader.Value)
End If
End Select
Loop

thanks,
rodchar
Nov 21 '05 #1
3 818
Hi rodchar,

That would be how I would do it, but my knowledge of XML is minimal (I'm
not a huge fan of it to be honest). I think you could also try loading
in the XML as an XmlDocument and calling SelectNodes, passing in the
appropriate XPath expression to match your strSearch nodes.

As to what that expression is, sorry, I can't help you there :)

Regards,
-Adam.

rodchar wrote:
hey all,

all i'm trying to do is retrieve text value from a particular node. and i
can get it the way shown below but was wondering if there was a cleaner way.
Because right now i'm looping thru the xml file looking for a particular node
and when it finds it i go ahead and read one more time to advance to the
value of the node. is this how it's normally done?
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Element 'Display beginning of element.
If reader.Name = "strSearch" Then
reader.Read()
RichTextBox1.AppendText(reader.Value)
End If
End Select
Loop

thanks,
rodchar

Nov 21 '05 #2
Rodchar,

It depends what your XML file is. When it is a document than in my opinion
the most easy is the nodereader.

When it is a dataset (that has only elements) you can read it as a dataset
(from what I get the idea) than in my opinion the most easy is..

dim ds as new dataset
ds.readxml("ThePath")

I hope this helps?

Cor
Nov 21 '05 #3
thanks everyone.

"Cor Ligthert" wrote:
Rodchar,

It depends what your XML file is. When it is a document than in my opinion
the most easy is the nodereader.

When it is a dataset (that has only elements) you can read it as a dataset
(from what I get the idea) than in my opinion the most easy is..

dim ds as new dataset
ds.readxml("ThePath")

I hope this helps?

Cor

Nov 21 '05 #4

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

Similar topics

1
by: Cy | last post by:
I have a form that contains several browse fields for users to upload files. There is also a hidden field that is populated using javascript. This script reads the value of the browse field,...
0
by: Eric Lilja | last post by:
Hello, I have a text file that contains a number of entries describing a recipe. Each entry consists of a number of strings. Here's an example file with only one entry (recipe): Name=Maple Quill...
3
by: Carl Lindmark | last post by:
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I believe the question is better suited in this XML group* Hello all, I'm having some problems understanding all the ins and...
11
by: Matt DeFoor | last post by:
I have some log files that I'm working with that look like this: 1000000000 3456 1234 1000000001 3456 1235 1000020002 3456 1223 1000203044 3456 986 etc. I'm trying to read the file...
30
by: siliconwafer | last post by:
Hi All, I want to know tht how can one Stop reading a file in C (e.g a Hex file)with no 'EOF'?
8
by: Andrew Robert | last post by:
Hi Everyone. I tried the following to get input into optionparser from either a file or command line. The code below detects the passed file argument and prints the file contents but the...
8
by: Shalaka Joshi | last post by:
Hi, I have binary file say, "test.bin". I write "FF" in the file and expect my code to read 255 for me. char * lbuf; int lreadBytes ; long lData; FILE *pFile = fopen ("c:\\testbin","rb");
0
by: EPDJ | last post by:
Well, I have to edit a program which we previously used for reading a header file to be able to read a trailer from a .dat file. The .dat file consists of 5 entries in each record and I am assuming...
13
by: swetha | last post by:
HI Every1, I have a problem in reading a binary file. Actually i want a C program which reads in the data from a file which is in binary format and i want to update values in it. The file...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.