XMLReader and VB.Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I need a few suggestions. I have the following XML segment:
<LookUp>
<ControlType>CheckBoxGroup</ControlType>
<DBField>LastMedDate</DBField>
<ControlName>cmbGoal1</ControlName>
<Values VALUE="0" BookMark="Goal1Progress"/>
<Values VALUE="1" BookMark="Goal1NoProgress"/>
<Values VALUE="2" BookMark="Goal1NA"/>
</LookUp>
I have code that will read everything except the "Values" elements. Here is
the code:
While reader.Read()
Select Case (reader.NodeType)
Case XmlNodeType.Element
If (reader.Name = "DBField") Then
ReportElement.DBField() = reader.ReadElementString()
End If
If (reader.Name = "BookMark") Then
ReportElement.BookMark = reader.ReadElementString()
End If
If (reader.Name = "ControlName") Then
ReportElement.ControlName = reader.ReadElementString()
End If
If (reader.Name = "ColumnIndex") Then
ReportElement.ColumnIndex = reader.ReadElementString()
End If
If (reader.Name = "ControlType") Then
ReportElement.ControlType = reader.ReadElementString()
End If
If (reader.Name = "Values") Then
ReportElement.AddValue (0, reader.ReadElementString())
End If
case XmlNodeType.EndElement
If (reader.Name = "LookUp") then
al.Add(ReportElement)
ReportElement.Reset()
End If
End Select
End While

I've tried a few different things to get the Values elements such as:
reader.GetAttribute("BookMark")
But it returns "Nothing" in the Command window.
Could someone please let me know how to get the values element. Thanks
Michael
 
Are you using serialization to generate the XML?
 
Hi Chris,
THanks for the reply. I just bought a book Yesterday and found my answer
there. I needed to use the MoveToNextAttribute of the reader object. Once I
did that, I was able to get into the attributes. Thanks for the reply.
Michael Lee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top