Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27034

VS 2010 Reading XML in loop

$
0
0
Happy New Year Everyone.

Hope you all had a good christmas and New Year and not to bad hangovers presently :-)

Was hoping for a bit of advice with reading XML documents. I normally only have to read xml documents which are fully known however I am now coming to a XML doc that structure is known and simple its repeated for an unspecified amount of times. Here is a sample of the XML Doc:


<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<SHOUTCASTSERVER>
<SONGHISTORY>
<SONG>
<PLAYEDAT>1357060815</PLAYEDAT>
<TITLE>Skrillex - Sick Bubblegum</TITLE>
</SONG>
<SONG>
<PLAYEDAT>1357060580</PLAYEDAT>
<TITLE>Tinie Tempah - Pass Out</TITLE>
</SONG>
</SONGHISTORY>
</SHOUTCASTSERVER>

What I now need to do is extract the Title of each song (and the played at but thats less important)

what i have so far is:

Code:

Dim XMLFile As String = Application.StartupPath & "\songhistory.xml"
        Dim xmlDoc As New XmlDocument

        xmlDoc.Load(XMLFile) 'opens XML file
        Dim node As XmlNode = xmlDoc.SelectSingleNode("/SHOUTCASTSERVER/SONGHISTORY") 'select "sClass" node


        For Each inst As XmlNode In node.ChildNodes
            For Each sProperty As XmlNode In inst.ChildNodes

                MessageBox.Show(sProperty.Name.ToString)
                MessageBox.Show(sProperty.Value.ToString)


                'If sProperty.Name = "TITLE" Then
                'MessageBox.Show(sProperty.Value)
                'End If

            Next
        Next

The Name's come out correctly but the values always = nothing.

Thanks,
Max

Viewing all articles
Browse latest Browse all 27034

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>