472,807 Members | 3,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,807 software developers and data experts.

Problem accessing complex XML child node when using Dataset

Hello,
I'm having problems accessing a complex XML child node (latitude &
longitude), and passing it to a function when the XML file has been read
into a DataSet. Specifically, the returned object from accessing the
'latitude' and 'longitude' nodes is not a DataTable (as specified in the
MSDN). I'm not sure what type is being returned, nor how to go about
finding out. Any pointers would be appreciated. Below is the relevent
Error message, XML, and VB code. Thanks for your time and attention.

Regards,
N. Demos
Error Msg:
------------
Exception Details: System.InvalidCastException: Specified cast is not valid.
XML:
--------
<cities>
<city>
<name>Abidjan</name>
<state>Ivory Coast</state>
<latitude>
<deg>5</deg>
<min>19</min>
<sec>0</sec>
<hemisphere>N</hemisphere>
</latitude>
<longitude>
<deg>4</deg>
<min>2</min>
<sec>0</sec>
<hemisphere>W</hemisphere>
</longitude>
</city>
.....
</cities>
ASP (VB)
--------
Public lstbxCities1 As ListBox
Public lblMon As Label

Public Sub Page_Load(Source As Object, E As EventArgs)
Dim dataSet As DataSet = LoadCityData()

If Not dataSet Is Nothing Then
Dim zRow As DataRow

For Each zRow In dataSet.Tables(0).Rows
Dim lstitmListItem As New ListItem()
lstitmListItem.text = zRow.Item("name") & ", " & zRow.Item("state")

'*** Problem Occurs Here ***
lstitmListItem.value = "latitude:" &
ToDegreeString(zRow.Item("latitude")) & _
"longitude:" & ToDegreeString(zRow.Item("longitude"))

lstbxCities1.Items.Add(lstitmListItem)
Next
lstbxCities1.Height = New Unit(20.0, UnitType.EM)
End If

End Sub

Function ToDegreeString(dtblCoords As DataTable) As String
Dim zRow As DataRow = dtblCoords.Rows(0)
Dim dTotDegrees As Double

Dim dDeg As Double = XmlConvert.ToDouble(zRow.Item("deg"))
Dim dMin As Double = XmlConvert.ToDouble(zRow.Item("min"))
Dim dSec As Double = XmlConvert.ToDouble(zRow.Item("sec"))

dTotDegrees = DMSToDegrees(dDeg, dMin, dSec)

Dim strOutput As String = XmlConvert.ToString(dTotDegrees) & "," &
zRow.Item("hemisphere") & ";"

Return strOutput
End Function
--
Change "seven" to a digit to email me.
Nov 19 '05 #1
0 1537

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

Similar topics

9
by: F. Da Costa | last post by:
Hi, Does anybody know why IE5+ does *not* honour array objects (like a table) across a session? Example: Frame A contains a var tableVar which is set via form Frame B (on init) using...
0
by: Max | last post by:
Suppose we have an object hierarchy in XSD. For example, let us take Control, Label, TextBox and LinkLabel windows controls. Each control has some properties which are represented as elements....
3
by: MrNobody | last post by:
Ok, so I'm absoultely positive this was working last night, but today I'm getting this error in my program when I try to add a child node to a parent node of a tree... The error says: ...
2
by: RJN | last post by:
Hi I need help in writing a recursive function. My table structure is as below. InstanceId LevelId ParentId 100 1 null 101 2 ...
2
by: Tony Girgenti | last post by:
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I used the XML Designer to create an XML .XSD...
4
by: SteveT | last post by:
I am wanting to populate several treeviews, one for the <TRs> group and one for the <TGsgroup. Is there a simplier way to populate the Treeview than the one I did below? It seems difficult to...
0
by: Alex Brown | last post by:
Is it a problem to attach Non-static site map providers under one that inherits from StaticSiteMapProvider ? We are implementing a custom site map provider for a website that is being converted...
2
by: Richard Carpenter | last post by:
I have a four-page tabcontrol with a gridview on each page. I have the primary key column of each gridview set to hidden (visible = false), but it still shows up on all but the first page. Anyone...
2
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Have a complex process where I need to Import a large amount of data then run some transformations on this data then import into DataBase. The transformation involves multiple fields and multiple...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.