473,396 Members | 1,915 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 File - Select Individual Data Items

Ben
Hi

I am a newbe when it comes to XML. I have the Schema below:

<XMLRoot xmlns="http://tempuri.org/xmlTesting.xsd">
<Data1>
<Country>My First Country</Country>
<Town>My Town</Town>
<Link>http://www.MyWebsite.com/</Link>
</Data1>
</XMLRoot>

I can databind a grid etc, but want to work with individual items, I want to
do a number of things:

1) get a distinct list of all countries
2) get all towns and links for a specific country

I will then loop though the results and list them in an ASPX page

Any advice on how to do this would be much appricated.

Thanks
B

PS we are currently using framework 1.1
Apr 8 '07 #1
2 1261
There are a plethera of ways to start, a bit of a learning curve to
overcome.

Without even using utilities that are available in the System.XML namespace,
you can accomplish your tasks.

Take a look at SelectNodes()
Take a look at SelectSingleNode()

Take a look at dictionary and hashtable objects
Take a look at dataset and datatable objects

Then you can make it more simple and delve deeper into the utilities
provided within the XML namespace.
"Ben" <Be*@Newsgroups.microsoft.comwrote in message
news:Og******************@TK2MSFTNGP04.phx.gbl...
Hi

I am a newbe when it comes to XML. I have the Schema below:

<XMLRoot xmlns="http://tempuri.org/xmlTesting.xsd">
<Data1>
<Country>My First Country</Country>
<Town>My Town</Town>
<Link>http://www.MyWebsite.com/</Link>
</Data1>
</XMLRoot>

I can databind a grid etc, but want to work with individual items, I want
to do a number of things:

1) get a distinct list of all countries
2) get all towns and links for a specific country

I will then loop though the results and list them in an ASPX page

Any advice on how to do this would be much appricated.

Thanks
B

PS we are currently using framework 1.1

Apr 9 '07 #2
Ben
Hi

Thanks for your post, I have researched as you say and have a good solution
except I am having problems alphabetically sorting the results:

'load the xml file

Dim xtr As XmlTextReader = New
XmlTextReader(Server.MapPath(gstrXMLCountries))

xtr.WhitespaceHandling = WhitespaceHandling.None

Dim xd As XmlDocument = New XmlDocument

xd.Load(xtr)

'retrieve matching nodes

Dim xnl As XmlNodeList = xd.DocumentElement.SelectNodes(tbXPath.Text)

'output the results

lblOutput.Text = ""

Dim xnod As XmlNode

For Each xnod In xnl

'for elements display the corresponding text entity

If xnod.NodeType = XmlNodeType.Element Then

lblOutput.Text += (xnod.NodeType.ToString & ": " & xnod.Name & " = " &
xnod.FirstChild.Value & "&lt;br/&gt;")

Else

lblOutput.Text += (xnod.NodeType.ToString & ": " & xnod.Name & " = " &
xnod.Value & "&lt;br/&gt;")

End If

Next

'clean up

xtr.Close()

Any help would be much appreicated

Thanks

B

"AMDRIT" <am****@hotmail.comwrote in message
news:uv**************@TK2MSFTNGP04.phx.gbl...
There are a plethera of ways to start, a bit of a learning curve to
overcome.

Without even using utilities that are available in the System.XML
namespace, you can accomplish your tasks.

Take a look at SelectNodes()
Take a look at SelectSingleNode()

Take a look at dictionary and hashtable objects
Take a look at dataset and datatable objects

Then you can make it more simple and delve deeper into the utilities
provided within the XML namespace.
"Ben" <Be*@Newsgroups.microsoft.comwrote in message
news:Og******************@TK2MSFTNGP04.phx.gbl...
>Hi

I am a newbe when it comes to XML. I have the Schema below:

<XMLRoot xmlns="http://tempuri.org/xmlTesting.xsd">
<Data1>
<Country>My First Country</Country>
<Town>My Town</Town>
<Link>http://www.MyWebsite.com/</Link>
</Data1>
</XMLRoot>

I can databind a grid etc, but want to work with individual items, I want
to do a number of things:

1) get a distinct list of all countries
2) get all towns and links for a specific country

I will then loop though the results and list them in an ASPX page

Any advice on how to do this would be much appricated.

Thanks
B

PS we are currently using framework 1.1


Apr 14 '07 #3

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

Similar topics

2
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of...
2
by: Brian | last post by:
Hello, I have a text file I'm attempting to parse. There are about 50 fixed width fields in each line / row. For example (shortened for brevity): W1234Somebody East 101110001111010101...
4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
5
by: hiroshi ochi | last post by:
Hello, Using MSIE 6.0 and above, with javascript is it possible to display an individual tooltip for each item in a listbox? I need this functionality to show the listitems that are longer...
3
by: Macca | last post by:
Hi, I am writing a C# application that needs a lot of calibration data. In a previous C++ application, i used a text file which displayed the various calibration data, between 25 and 40...
1
by: gfexrd | last post by:
Hi, I need to know how to retrieve many records from an access datafile, one by one. Let me explain you. I have an array with 2 column by 1000 rows, in one column I have part code, the other...
2
by: richardkreidl | last post by:
I heard of importing your xml doc into a dataset, then sort the dataset and re-populate your xml, but I'm not sure how to code this or is there another way of sorting a XML file? I not familiar...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
0
by: Hags007 | last post by:
I have a XML file I am working with. This file has been created by hand and I now need to develop a PHP script that will create it in the same format. Here is what I have thus far: $query =...
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...
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,...
0
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...
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.