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

XML document

I have a single XML file containing forty records, with no child nodes. For
example, imagine a list of people's names, and birthdates with SSN.

I'd like to find the row of a person with SSN of 123456789. What's the
quickest way to:

1. Load the file from disk.
2. Find the "record" I want.
3. Walk through the other "fields" in this record to get birthdate, first
name and last name for this person?

For example, should I load the file into a DataSet, or use the XMLDocument
class? I will NOT be binding the data to a DataGrid or similar.

Thanks in advance.
Mark
Nov 21 '05 #1
3 1107
On 2004-09-14, Mark <fi******@idonotlikejunkmail.umn.edu> wrote:
I have a single XML file containing forty records, with no child nodes. For
example, imagine a list of people's names, and birthdates with SSN.

I'd like to find the row of a person with SSN of 123456789. What's the
quickest way to:

1. Load the file from disk.
2. Find the "record" I want.
3. Walk through the other "fields" in this record to get birthdate, first
name and last name for this person?

For example, should I load the file into a DataSet, or use the XMLDocument
class? I will NOT be binding the data to a DataGrid or similar.


With only forty records, speed probably shouldn't be your biggest
concern. Forty records are going to be read pretty quickly no matter
which class you use.

Still, for the general question, I'd say both of the above are the wrong
choice. Both require the entire file to be parsed into classes, and you
only want a little bit of the file. An XmlReader is probably the
fastest solution, but in this case I'd use an XPathNavigator, which is
faster than an XmlDocument or DataSet but still trivial to parse out
information from...

Imports System.Xml.XPath

Dim doc as new XPathDocument(filename)
Dim navigator as XPathNavigator = doc.CreateNavigator()

Dim iter As XPathNodeIterator = navigator.Select("/person[@ssn='123456789']")
If iter.MoveNext Then
Dim ssn As String = iter.Current.GetAttribute("ssn", "")
Dim fname As String = iter.Current.GetAttribute("fname", "")
...

Nov 21 '05 #2
load it into a dataset and use the data objects and commands on it to filter
it down to that (mainly the dataview object)
"Mark" <fi******@idonotlikejunkmail.umn.edu> wrote in message
news:eF**************@TK2MSFTNGP14.phx.gbl...
I have a single XML file containing forty records, with no child nodes.
For
example, imagine a list of people's names, and birthdates with SSN.

I'd like to find the row of a person with SSN of 123456789. What's the
quickest way to:

1. Load the file from disk.
2. Find the "record" I want.
3. Walk through the other "fields" in this record to get birthdate, first
name and last name for this person?

For example, should I load the file into a DataSet, or use the XMLDocument
class? I will NOT be binding the data to a DataGrid or similar.

Thanks in advance.
Mark

Nov 21 '05 #3
Mark,

Because there are different opinions,

I go in this case definitly for the dataset. However it can be a matter of
choise, when you are very well knowed with the XMLreader, than you can as
well take this one. Performance is no decisor in this and as David wrote,
they both have to be loaded first.

However thinking about loading a 40 row dataset from approx 40 characters is
spending time.

There are people who loads datassets from more than 10000 rows. (And there
are reasons for that think on ofline processing)

Cor

"Mark" <fi******@idonotlikejunkmail.umn.edu> schreef in bericht
news:eF**************@TK2MSFTNGP14.phx.gbl...
I have a single XML file containing forty records, with no child nodes. For example, imagine a list of people's names, and birthdates with SSN.

I'd like to find the row of a person with SSN of 123456789. What's the
quickest way to:

1. Load the file from disk.
2. Find the "record" I want.
3. Walk through the other "fields" in this record to get birthdate, first
name and last name for this person?

For example, should I load the file into a DataSet, or use the XMLDocument
class? I will NOT be binding the data to a DataGrid or similar.

Thanks in advance.
Mark

Nov 21 '05 #4

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

Similar topics

1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
2
by: Edward | last post by:
The below code builds 2 tables 4 rows by 4 cols. All cells have checkboxes. When checked, the checkboxes in the first column automatically check the remainder of the check boxes in the same row. ...
1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
6
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
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
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,...

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.