Accessing xml data for TabPage text

RoyLittle0

Active member
Joined
Nov 17, 2012
Messages
38
Location
Derby, Uk
Programming Experience
Beginner
Hi,

I an trying to access the nodes in my xml based on the selection made in a combobox and write the text to a TabControl/TabPages, the area i am struggling with is "TabControl1.TabPages(i).Text = myMachineName.Attributes.ItemOf("Page").InnerText" so based on the code below how would i get the information out


I can get it to display the Machine Type by using
VB.NET:
TabControl1.TabPages(i).Text = mySet.Attributes.ItemOf("Type").InnerText
But i just cant seem to grasp the Page Number

VB.NET:
    Public Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim NodeCount As Integer


        For Each mySet As XmlNode In myXMLDoc.GetElementsByTagName("Machine")
            If mySet.Attributes.ItemOf("Type").InnerText = ComboBox1.SelectedItem.ToString Then


                For Each myMachineName As XmlNode In mySet.SelectNodes("Page")
                    NodeCount = 1
                    For i = 0 To 19
                        TabControl1.TabPages(i).Text = myMachineName.Attributes.ItemOf("Page").InnerText
                    Next
                Next
            End If
        Next
    End Sub

XML
VB.NET:
<Root>
    <Machine Type="A Machine">
        <Page Number="Page 1, Machine A">
            <Title>1</Title>
            <TextBox>2</TextBox>
            <TextBox>3</TextBox>
            <TextBox>4</TextBox>        
            <PictureBox>5</PictureBox>
            <PictureBox>6</PictureBox>
            <PictureBox>7</PictureBox>
            <Link>8</Link>
        </Page>
        <Page Number="Page 2, Machine A">
            <Title>9</Title>
            <TextBox>10</TextBox>
            <TextBox>11</TextBox>
            <TextBox>12</TextBox>        
            <PictureBox>13</PictureBox>
            <PictureBox>14</PictureBox>
            <PictureBox>15</PictureBox>
            <Link>16</Link>        
        </Page>
        <Page Number="Page 3, Machine A">
            <Title>17</Title>
            <TextBox>18</TextBox>
            <TextBox>19</TextBox>
            <TextBox>20</TextBox>        
            <PictureBox>21</PictureBox>
            <PictureBox>22</PictureBox>
            <PictureBox>23</PictureBox>
            <Link>24</Link>        
        </Page>
    </Machine>
</Root>
 
Last edited:
Ok, i can now get to the point where i get all my TabPages to display the data from the first Node but i cant get them to increment on, ie Page 1, Page 2, Page 3 etc
all i get is Page 1, Page 1, Page 1

This is what i am using at the moment, any ideas what i am doing wrong ?
VB.NET:
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted        Dim i As Integer
        For Each mySet As XmlNode In myXMLDoc.GetElementsByTagName("Machine")
            If mySet.Attributes.ItemOf("Type").InnerText = ComboBox1.SelectedItem.ToString Then


                For Each myMachineName As XmlNode In mySet.SelectNodes("Page")
                    For i = 0 To 19
                        TabControl1.TabPages(i).Text = (myMachineName.Attributes.ItemOf("Number").InnerText)
                    Next
                Next
            End If
        Next
    End Sub
 

Latest posts

Back
Top