Strange XML

  • 13 years ago

     Hi all i was wondering wheather someone could explain how i would extract the string data in bold from the xml line bellow?




    I am using an xReader to read the file in another program but the structure is very different, the code i use for the other app us bellow. could someone please direct me in how i should change this code to suit the current xml, i will need to put 54.28,-8.48 from above into 2 seperate variables as i loop through the lines.

    Any help would be great many thanks

    Dim Country as String
    Dim RefPosLat As Double
    Dim RefPosLong As Double

    Name = xReader.GetAttribute("id").Split(",")(1)
    Dim trStr As String = Name.Trim()
    RefPosLat = xReader.ReadElementContentAsDouble
    Catch ex As Exception

    RefPosLat = CDbl("0.0000000000")

    End Try
    RefPosLong = xReader.ReadElementContentAsDouble
    Catch ex As Exception
    RefPosLong = CDbl("0.000000000")
    End Try


  • 13 years ago

    Hi there,

            Dim fstream As FileStream = Nothing
    Dim xmldoc As XmlDocument = Nothing
    Dim xmlelem As XmlElement = Nothing
    fstream = New FileStream("E:\WindowsApplication3\XMLFile1.xml", FileMode.Open, FileAccess.Read)

    xmldoc = New XmlDocument

    xmlelem = xmldoc.DocumentElement

    For Each node As XmlNode In xmlelem.SelectNodes("state")
    Dim tmp As String() = node.SelectSingleNode("loc").InnerText.Split(",")
    TextBox2.Text &= tmp(0) & " / " & tmp(1)
    Catch ex As Exception
    Throw ex
    If (Not IsNothing(fstream)) Then fstream.Close()
    End Try
  • 13 years ago

    Hi thanks for the reply it worked with a little tinkering thank you so much i am in your debt


    Many Thanks



  • 13 years ago

    no matter. you are welcome.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“You can stand on the shoulders of giants OR a big enough pile of dwarfs, works either way.”