mariyana 0 Newbie Poster

have a xml file as follows

<par def="1">
- <field type="keyword" name="ListBox_1" >
<keywords ui="listbox" readingorder="lefttoright" />
</field>
- <field type="keyword" name="ListBox_2" >
<keywords ui="listbox" readingorder="lefttoright" />
</field>
</par>
- <par>
- <field type="keyword" name="Combox_1" >
<keywords ui="combobox" />
</field>
- <field type="keyword" name="Combox_2" >
<keywords ui="combobox" />
</field>
</par>

In this ,first I have to check for the node "field" then move to the attribute "name" that gives the name of the control "ListBox_1". Then I have to get the "type" of "field". If it is "keyword" then I have to move to the "keywords" tag and get the tag value of "ui". If "ui" is listbox then i have print the name as "Listbox_1" . then iterating i have to get "Listbox_2"

The same with Combo box too.

I have writtent the following code :

Dim filename As String = TextBox1.Text
Dim reader As New XmlTextReader(filename)
Dim strList, strName, strListName, strComboName, strCheckName, strRadioName, strRichName, strDateName, strdate As String
reader.MoveToContent()

Do While reader.Read


'To get the valuees of textbox,label and button
Select Case reader.Name
Case "field"
strType = reader.GetAttribute("type")
If strType = "text" Then
strTextName = reader.GetAttribute("name")
Call Module1.TextBox(strTextName)
Call Module1.XSD_Change(strTextName)
Call Module1.SampleXML_change(strTextName)
Call Module1.template_Change(strTextName)
' MsgBox(strTextName)
GoTo 1
ElseIf strType = "keyword" Then
strName = reader.GetAttribute("name")
End If

Case "keywords"
strList = reader.GetAttribute("ui").ToString

If strList = "listbox" Then
strListName = strName
msgbox(strListName)
ElseIf strList = "combobox" Then
strComboName = strName
msgbox(ComboName)
End If

end select
loop

I have assumed that each tag is read in a sequential way: eg: field then keywords , then again field, keywords.

So according to me first when it reads "field" it stores the name Listbox_1 in the strName, then the following tag is "keywords", in which it checks the "ui" if it "listbox", it has to print the value "LIstbox_1" . then again it hs to read tag "field" tag which has "Listbox_2" as name.

But in my case it just gives the last value of the controls. Like "Listbox_2" in Listbox and Combox_2 for Combox. not the first values(Listbox_1,Combox_1)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.