pagego
Freshman
I have an xml file (http://www.weatherroom.com/xml/ext/97401). How can I put the temperatue (temp) value into a textbox?? Thanks for your help!
'create a stream reader give it the path of your xml file as a parameter
Dim streader As New StreamReader(XmlFilePath)
'read the content of the file into a string
Dim FileContent As String = streader.ReadToEnd
'close the stream reader
streader.Close()
'Now you have your file in a string
'we will parse it through XMLReader Class
'create a nametable
Dim nt As NameTable = New NameTable()
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)
nsmgr.AddNamespace("bk", "urn:sample")
'Create the XmlParserContext
Dim context As XmlParserContext = New XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
'Create the reader, giving it the string and the context
Dim reader As XmlTextReader = New XmlTextReader(FileContent, XmlNodeType.Document, context)
'move to first node
reader.MoveToContent()
'Keep reading until you reach the desired node (in your case) Temp
While reader.Read
If reader.Name = "Temp" Then
reader.Read()
'place the value in a textbox
txtTemp.Text = reader.Value
Exit While
End If
End While
'close the reader
reader.Close()