请问VB。NET怎么读取这个XML的数据?
<?xml version="1.0" encoding="gb2312"?>
<AutoUpdater>
<serverurl>123456789</serverurl>
</AutoUpdater>
请问怎么读出123456789 在线等。谢谢。
[解决办法]
Private Function GetXML(ByVal name As String) As String
Dim path As String
Dim hex As String = ""
path = Application.StartupPath
Try
Dim reader As New Xml.XmlTextReader(path)
reader.ReadToFollowing(name)
hex = reader.ReadString
reader.Close()
Catch ex As Exception
hex = -1
End Try
Return hex
End Function
读的时候 ,将XML放在EXE目录,调用GetXML(serverurl)
[解决办法]
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load("xx.xml")
Dim strNode As Xml.XmlNode= xmlDoc.SelectSingleNode("AutoUpdater")
Dim value As String = strNode.InnerText
'value = 123456789