|
-
Nov 8th, 2005, 08:55 PM
#1
Thread Starter
Addicted Member
Reading an XML File
Hi. I posted this topic over in the VB.NET forum, but I thougt I might have more luck here. I am trying to read an ASX file, which is an XML media playlist file. Here is an example:
Code:
<Asx Version = "3.0" >
<Title > Playlist3</Title>
<Param Name = "AllowShuffle" Value = "yes" />
<Entry>
<Duration value = "00:01:26.184" />
<Author > Pollini</Author>
<Param Name = "AverageLevel" Value = "1561" />
<Param Name = "Bitrate" Value = "128000" />
<Param Name = "FileSize" Value = "1380352" />
<Param Name = "FileType" Value = "mp3" />
<Param Name = "Is_Protected" Value = "False" />
<Param Name = "Is_Trusted" Value = "false" />
<Param Name = "IsVBR" Value = "False" />
<Param Name = "MediaType" Value = "audio" />
<Param Name = "PeakValue" Value = "16623" />
<Param Name = "SourceURL" Value = "C:\Documents and Settings\Dave\Desktop\mp3\Chopin_Etude_Pollini_02.mp3" />
<Title > Etude, Op. 10 No. 2</Title>
<Param Name = "type" Value = "local" />
<Param Name = "UserPlayCount" Value = "1" />
<Param Name = "WM/Composer" Value = "Chopin" />
<Param Name = "WM/Genre" Value = "Classical" />
<Param Name = "WM/Year" Value = "1972" />
<Ref href = "mp3\Chopin_Etude_Pollini_02.mp3"/>
</Entry>
<Entry>
<Duration value = "00:03:42.832" />
<Author > Pollini</Author>
<Param Name = "Bitrate" Value = "128000" />
<Param Name = "FileSize" Value = "3565568" />
<Param Name = "FileType" Value = "mp3" />
<Param Name = "Is_Protected" Value = "False" />
<Param Name = "Is_Trusted" Value = "false" />
<Param Name = "IsVBR" Value = "False" />
<Param Name = "MediaType" Value = "audio" />
<Param Name = "SourceURL" Value = "C:\Documents and Settings\Dave\Desktop\mp3\Chopin_Etude_Pollini_03.mp3" />
<Title > Etude, Op. 10 No. 3</Title>
<Param Name = "type" Value = "local" />
<Param Name = "WM/Composer" Value = "Chopin" />
<Param Name = "WM/Genre" Value = "Classical" />
<Param Name = "WM/Year" Value = "1972" />
<Ref href = "mp3\Chopin_Etude_Pollini_03.mp3"/>
</Entry>
<Entry>
<Duration value = "00:02:2.104" />
<Author > Pollini</Author>
<Param Name = "FileSize" Value = "1955840" />
<Param Name = "Is_Protected" Value = "False" />
<Param Name = "IsVBR" Value = "False" />
<Param Name = "SourceURL" Value = "C:\Documents and Settings\Dave\Desktop\mp3\Chopin_Etude_Pollini_04.mp3" />
<Title > Etude, Op. 10 No. 4</Title>
<Param Name = "WM/Composer" Value = "Chopin" />
<Param Name = "WM/Genre" Value = "Classical" />
<Param Name = "WM/Year" Value = "1972" />
<Ref href = "mp3\Chopin_Etude_Pollini_04.mp3"/>
</Entry>
<Entry>
<Duration value = "00:02:29.793" />
<Author > Pollini</Author>
<Param Name = "FileSize" Value = "2398208" />
<Param Name = "Is_Protected" Value = "False" />
<Param Name = "IsVBR" Value = "False" />
<Param Name = "SourceURL" Value = "C:\Documents and Settings\Dave\Desktop\mp3\Chopin_Etude_Pollini_24.mp3" />
<Title > Etude, Op. 24 No. 12</Title>
<Param Name = "WM/Composer" Value = "Chopin" />
<Param Name = "WM/Genre" Value = "Classical" />
<Param Name = "WM/Year" Value = "1972" />
<Ref href = "mp3\Chopin_Etude_Pollini_24.mp3"/>
</Entry>
</Asx>
Here is the code that I have, but I don't know what I should put at '"SourceURL"' in m_node.Attributes.GetNamedItem("Value").Value. Also, is my nodelist correct or no?
VB Code:
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
'Create the XML Document
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.Load(TheFile)
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/ASX/Entry/Param")
'Loop through the nodes
For Each m_node In m_nodelist
'Get the Gender Attribute Value
Dim FileSource = m_node.Attributes.GetNamedItem("SourceURL").Value
'Write Result to the Console
playlistPath.Items.Add(FileSource)
Next
A programmer is a person who fixes a problem you did not know you had in a way that you cannot understand.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|