Hi guys I'm a beginner, i have a problem to read a attribute from a XML file, How can i read sub attribute from repeated attribute?
I use this code but allways return (name) from first block
How Can Read (Name) Attribute from 2nd Block or 3rd Block?
HTML Code:
<weatherdata>
<location>
<name>Tehran</name>
<type/>
<country>IR</country>
<timezone>12600</timezone>
<location altitude="0" latitude="35.74" longitude="51.58" geobase="geonames" geobaseid="112931"/>
</location>
<credit/>
<meta>
<lastupdate/>
<calctime>0</calctime>
<nextupdate/>
</meta>
<sun rise="2020-10-05T02:31:49" set="2020-10-05T14:12:01"/>
<forecast>
<time from="2020-10-05T15:00:00" to="2020-10-05T18:00:00">
<symbol number="803" name="broken clouds" var="04n"/>
<precipitation probability="0.45"/>
<windDirection deg="37" code="NE" name="NorthEast"/>
<windSpeed mps="0.58" unit="m/s" name="Calm"/>
<temperature unit="celsius" value="17.2" min="17.2" max="18.46"/>
<feels_like value="15.9" unit="celsius"/>
<pressure unit="hPa" value="1021"/>
<humidity value="48" unit="%"/>
<clouds value="broken clouds" all="57" unit="%"/>
<visibility value="10000"/>
</time>
<time from="2020-10-05T18:00:00" to="2020-10-05T21:00:00">
<symbol number="500" name="light rain" var="10n"/>
<precipitation probability="0.36" unit="3h" value="0.2" type="rain"/>
<windDirection deg="45" code="NE" name="NorthEast"/>
<windSpeed mps="2" unit="m/s" name="Light breeze"/>
<temperature unit="celsius" value="17.29" min="17.29" max="17.64"/>
<feels_like value="14.75" unit="celsius"/>
<pressure unit="hPa" value="1020"/>
<humidity value="44" unit="%"/>
<clouds value="broken clouds" all="60" unit="%"/>
<visibility value="10000"/>
</time>
<time from="2020-10-05T21:00:00" to="2020-10-06T00:00:00">
<symbol number="803" name="broken clouds" var="04n"/>
<precipitation probability="0.08"/>
<windDirection deg="109" code="ESE" name="East-southeast"/>
<windSpeed mps="0.9" unit="m/s" name="Calm"/>
<temperature unit="celsius" value="16.72" min="16.72" max="16.77"/>
<feels_like value="14.72" unit="celsius"/>
<pressure unit="hPa" value="1020"/>
<humidity value="42" unit="%"/>
<clouds value="broken clouds" all="58" unit="%"/>
<visibility value="10000"/>
</time>
</forecast>
</weatherdata>
I use this code but allways return (name) from first block
HTML Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim e1 As String
Dim m_xmld As XmlDocument = New XmlDocument
m_xmld.Load("forecast.xml")
Dim loc_node As XmlNode = m_xmld.SelectSingleNode("weatherdata/forecast/time/windSpeed")
e1 = (loc_node.Attributes("name").Value)
MessageBox.Show(e1)
End Sub