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

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.

N. Demos
Error Msg:
Exception Details: System.InvalidCastException: Specified cast is not valid.
<state>Ivory Coast</state>
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.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

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...
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....
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: ...
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 ...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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 ...
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...
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=()=>{
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.