[RESOLVED] get values from xml elements
Here's a portion of my xml file
<sources>
<comicbooks>
<source>
<profile>0</profile>
<name>Main</name>
<path>*mypath not showing*</path>
</source>
</comicbooks>
</sources>
I am also using a schema file for the sources.xml file.
Here's my code:
Code:
Dim fileSources As IO.File
If fileSources.Exists(filePath & "sources.xml") Then
Try
Dim Sources As XDocument = XDocument.Load(filePath & "sources.xml")
lblSourcesStatus1.Text = "Sources file found and loaded!"
lblSourcesStatus2.Text = "path: " & filePath & "sources.xml"
For Each source As XElement In Sources...<sources>.<comicbooks>.<source>
lbSources.Items.Add(source.<path>.Value)
Label2.Text = source.<path>.Value
Next
Catch ex As Exception
lblSourcesStatus1.Text = "Sources file found, but could not be loaded!"
lblSourcesStatus2.Text = "path: " & filePath & "sources.xml"
End Try
Else
lblSourcesStatus1.Text = "No sources file found!"
lblSourcesStatus2.Text = "expected path: " & filePath & "sources.xml"
End If
lbSources doesn't get populated with anything and Label2 doesn't change either.
Please help.
Re: get values from xml elements
Disregard, my XML file had something before the "<?xml version="1.0" encoding="utf-8" ?>" tag, the file wasn't being recognized or loaded.