I'm new to using XML with visual basic. What I'm trying to accomplish is loading data into textboxes based on the items node. I have done that with static addresses. What I want to do now however is be able to change it based upon the attribute of the screen node called "ID".
For example if the attribute ID from the screen node = 36 I want aLabel.text to equal "Apples". I'll accept an answer in C# too, I can do either or.
XML Example
<Screen attribute ="35">
<A>Chrono Trigger</A>
</Screen>
<Screen attribute ="36">
<A>Apples</A>
</Screen>
VB.Net Code
doc.Load(files)
Static NodeNumber As Integer = 0
RichTextBox1.Text = (doc.DocumentElement.SelectSingleNode("/Main/Screen").Attributes.ItemOf("ID").InnerText)
aLabel.Text = (doc.DocumentElement.SelectSingleNode("/Main/Screen/A").InnerText)
bLabel.Text = (doc.DocumentElement.SelectSingleNode("/Main/Screen/B").InnerText)
cLabel.Text = (doc.DocumentElement.SelectSingleNode("/Main/Screen/C").InnerText)
dLabel.Text = (doc.DocumentElement.SelectSingleNode("/Main/Screen/D").InnerText)
No comments:
Post a Comment