XML works in console not in text boxes

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
 
A

Andrew Morton

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
 

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

Top