470,631 Members | 2,175 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

XML displays in console but not in text boxes

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
Jul 3 '08 #1
3 1563
John Meyer wrote:
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
With VB.NET 2008 you could use LINQ to XML instead of Xml(Text)Reader,
see MSDN online or your local copy:
http://msdn.microsoft.com/en-us/library/bb387098.aspx

As for your code above, with the XmlReader API you can use code like this:
Using reader As XmlReader = XmlReader.Create(strSearchString)
While reader.Read()
If reader.NodeType = XmlNodeType.Element And reader.Name =
"Title" Then
Me.txtTitle.Text = reader.ReadString()
Else if reader.NodeType = XmlNodeType.Element And reader.Name =
"AuthorsText" Then
Me.txtAuthors.Text = reader.ReadString()
End If
End While
End Using

If that does not help then show us how a sample of the XML looks.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 3 '08 #2
Rack, that worked! Thanks

Martin Honnen wrote:
John Meyer wrote:
>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

With VB.NET 2008 you could use LINQ to XML instead of Xml(Text)Reader,
see MSDN online or your local copy:
http://msdn.microsoft.com/en-us/library/bb387098.aspx

As for your code above, with the XmlReader API you can use code like this:
Using reader As XmlReader = XmlReader.Create(strSearchString)
While reader.Read()
If reader.NodeType = XmlNodeType.Element And reader.Name = "Title"
Then
Me.txtTitle.Text = reader.ReadString()
Else if reader.NodeType = XmlNodeType.Element And reader.Name =
"AuthorsText" Then
Me.txtAuthors.Text = reader.ReadString()
End If
End While
End Using

If that does not help then show us how a sample of the XML looks.
Jul 3 '08 #3
Yeah, I originally posted this in m.p.vb.general.discussion but somebody
said that I was talking Visual Basic.NET, not real Visual Basic. Go fig.
Martin Honnen wrote:
John Meyer wrote:
>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

With VB.NET 2008 you could use LINQ to XML instead of Xml(Text)Reader,
see MSDN online or your local copy:
http://msdn.microsoft.com/en-us/library/bb387098.aspx

As for your code above, with the XmlReader API you can use code like this:
Using reader As XmlReader = XmlReader.Create(strSearchString)
While reader.Read()
If reader.NodeType = XmlNodeType.Element And reader.Name = "Title"
Then
Me.txtTitle.Text = reader.ReadString()
Else if reader.NodeType = XmlNodeType.Element And reader.Name =
"AuthorsText" Then
Me.txtAuthors.Text = reader.ReadString()
End If
End While
End Using

If that does not help then show us how a sample of the XML looks.
Jul 3 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John Wright | last post: by
2 posts views Thread by John Meyer | last post: by
5 posts views Thread by cs_hart | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.