473,396 Members | 1,816 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.

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 1563

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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.