473,320 Members | 2,080 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 - traversing in VB

Hi, I have an XML file that looks something like this:

- <Geo>
<state>Alabama</state>
<capital>Montgomery</capital>
<abbrev>AL</abbrev>
<timezone>C</timezone>
</Geo>
- <Geo>
<state>Alaska</state>
<capital>Juneau</capital>
<abbrev>AK</abbrev>
<timezone>A</timezone>
</Geo>

so on and so forth. I want to write a function in VB, where if the
function is sent AL (abbreviation) it returns the state name or some
other information in that group. I worked with XML long time ago, and
can't recall right now how to do this. Can someone refresh my memory?
BTW, I want to use XMLTextReader to do this.

Thanks.
Nov 18 '05 #1
1 1334
Hello as*******@hotmail.com,
Hi, I have an XML file that looks something like this:

- <Geo>
<state>Alabama</state>
<capital>Montgomery</capital>
<abbrev>AL</abbrev>
<timezone>C</timezone>
</Geo>
- <Geo>
<state>Alaska</state>
<capital>Juneau</capital>
<abbrev>AK</abbrev>
<timezone>A</timezone>
</Geo>
so on and so forth. I want to write a function in VB, where if the
function is sent AL (abbreviation) it returns the state name or some
other information in that group. I worked with XML long time ago, and
can't recall right now how to do this. Can someone refresh my memory?
BTW, I want to use XMLTextReader to do this.


I dont think that you'll be able to use an XmlTextReader to accomplish this, since the XmlTextReader is a forward only cursor through the Xml.

I would think that the best way to accomplish this would be to load the document in an XmlDocument and then use an XPATH query to get the appropriate Geo node.

Example (Excuse the C# code. My VB.NET is rusty):
XmlNode node = document.SelectSingleNode("/Geo[Abbrev = 'AL']");
string stateName = node["state"].InnerText;

Since this Xml is more than likely readonly, you could also look at using the XPathNavigator class to increase performance a little.

HTH!

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #2

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

Similar topics

1
by: w.p. | last post by:
Hello! I want change default tab traversing in my app. But i don't know how to do it :( Belowe i include simple example - i want change default tab order: radiobutton "mode11" -> radiobutton...
2
by: Jim Cobban | last post by:
I am using Xerces to read an XML file and load it into a DOM so I can update it and subsequently serialize the updated DOM. The problem I have is that as I traverse the DOM I would like to inform...
3
by: Plamen Valtchev | last post by:
This is my problem: From JavaScript I want to find the list of all defined/loaded JavaScript functions/objects/names within the current scope (html page in a browser). the page could contain...
1
by: alfred | last post by:
Hi my question is on traversing a tree with DOM. how would I be able to traverse 2 trees at the same time. I have 2 XML documents, with similar nodes. I would like to traverse 1 xml document,...
0
by: thomson | last post by:
Hi all, can any one tell me which is fast traversing a XML file or a hash file is fast, i got few few field names and values in XML which i will use to retrieve. I can use Hash File also to do the...
2
by: thomson | last post by:
Hi all, can any one tell me which is fast traversing a XML file or a hash file is fast, i got few few field names and values in XML which i will use to retrieve. I can use Hash File also to do the...
11
hi
by: Ganga | last post by:
Can anybody tell me how to find out middle node of a link list without traversing all the nodes.
4
by: plmanikandan | last post by:
Hi, I am new to link list programming.I need to traverse from the end of link list.Is there any way to find the end of link list without traversing from start(i.e traversing from first to find the...
30
by: asit | last post by:
We kno that data can be pushed onto the stack or popped 4m it. Can stack be traversed ??
1
by: somcool | last post by:
I am facing an error while traversing a query in MS Access Details - When I click a button, a form which has the query opens up. There are certain fields which are in the form of combo box in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.