XML works in console not in text boxes

  • Thread starter Thread starter John Meyer
  • Start date Start date
J

John Meyer

The console code is working just fine, but it isn't putting in the text
boxes.

P.S I'm using a while loop, but I'm only expecting one answer but I
haven't found a good way to process one record.

Private Sub btnFindByISBN_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnFindByISBN.Click
Dim strSearchString As String

strSearchString = "http://isbndb.com/api/books.xml?access_key="
& "CYGCL3GT" & "&index1=isbn&value1=" & Me.txtISBN.Text



Dim reader As XmlTextReader = New XmlTextReader(strSearchString)
Do While (reader.Read())
Console.WriteLine(reader.Name)
Console.WriteLine(reader.Value)

Select Case reader.Name
Case "Title"
Me.txtTitle.Text = reader.Value
Case "AuthorsText"
Me.txtAuthors.Text = reader.Value
End Select
Loop




End Sub

Visual Basic.NET 2008
 
John said:
The console code is working just fine, but it isn't putting in the
text boxes.

P.S I'm using a while loop, but I'm only expecting one answer but I
haven't found a good way to process one record.

Private Sub btnFindByISBN_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnFindByISBN.Click
Dim strSearchString As String

strSearchString =
"http://isbndb.com/api/books.xml?access_key=" & "CYGCL3GT" &
"&index1=isbn&value1=" & Me.txtISBN.Text Dim reader As XmlTextReader = New
XmlTextReader(strSearchString) Do While (reader.Read())
Console.WriteLine(reader.Name)
Console.WriteLine(reader.Value)

Select Case reader.Name
Case "Title"
Me.txtTitle.Text = reader.Value

You are /replacing/ the content of txtTitle.Text every time, so if the last
reader.Value is empty or white space it'll look like there's nothing there.

txtTitle.Text &= reader.Value

Andrew
 
Back
Top